diff --git a/backend/src/index.ts b/backend/src/index.ts new file mode 100644 index 0000000..4c653d0 --- /dev/null +++ b/backend/src/index.ts @@ -0,0 +1,26 @@ +import express from "express"; +import cors from "cors"; +import path from "path"; +import imageRoutes from "./routes/image"; + +const app = express(); +const port = process.env.PORT || 3000; + +app.use(cors()); +app.use(express.json()); + +// API routes +app.use("/api", imageRoutes); + +// Serve frontend static build +const publicDir = path.join(__dirname, "public"); +app.use(express.static(publicDir)); + +// Fallback to index.html for SPA routing +app.get("*", (_req, res) => { + res.sendFile(path.join(publicDir, "index.html")); +}); + +app.listen(port, () => { + console.log(`Server listening on port ${port}`); +}); \ No newline at end of file