diff --git a/package.json b/package.json index d1a5cee..271fba2 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "db:push": "drizzle-kit push --config server/drizzle.config.ts", "db:seed": "bun run server/db/seed.ts", "dev": "concurrently \"npm run client:dev\" \"npm run server:dev\"", - "build": "npm run client:build && npm run server:build", + "build": "npm run client:build", "start": "NODE_ENV=production bun run server/main.ts", "start:worker": "NODE_ENV=production bun run server/queue-worker.ts" }, diff --git a/server/main.ts b/server/main.ts index d6915d6..4f1efd6 100644 --- a/server/main.ts +++ b/server/main.ts @@ -19,20 +19,27 @@ app.onError((err, c) => { // Allow all origin on development if (__DEV) { app.use(cors({ origin: "*" })); +} else { + app.use(httpLogger()); } // Health check app.get("/health", (c) => c.text("OK")); -// Serve prod client app -if (__PROD) { - app.use(httpLogger()); - app.use(serveStatic({ root: "./dist/client" })); -} - // API router app.route("/api", router); +// Serve prod client app +if (__PROD) { + const CLIENT_DIST_DIR = "./dist"; + app.use(serveStatic({ root: CLIENT_DIST_DIR })); + app.get("*", async (c) => { + const index = Bun.file(CLIENT_DIST_DIR + "/index.html"); + const content = await index.text(); + return c.html(content); + }); +} + Bun.serve({ fetch: app.fetch, hostname: HOST, diff --git a/vite.config.ts b/vite.config.ts index 1243f9b..68fb642 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,10 +11,6 @@ export default defineConfig({ "@server": path.resolve(__dirname, "./server"), }, }, - build: { - outDir: "dist/client", - emptyOutDir: true, - }, server: { proxy: { "/api": process.env.API_BASEURL || "http://127.0.0.1:5589",