mirror of
https://github.com/khairul169/github-leaderboard.git
synced 2025-04-28 15:39:31 +07:00
fix: fix client rewrite url
This commit is contained in:
parent
18b0f47c49
commit
22ea803add
@ -15,7 +15,7 @@
|
|||||||
"db:push": "drizzle-kit push --config server/drizzle.config.ts",
|
"db:push": "drizzle-kit push --config server/drizzle.config.ts",
|
||||||
"db:seed": "bun run server/db/seed.ts",
|
"db:seed": "bun run server/db/seed.ts",
|
||||||
"dev": "concurrently \"npm run client:dev\" \"npm run server:dev\"",
|
"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": "NODE_ENV=production bun run server/main.ts",
|
||||||
"start:worker": "NODE_ENV=production bun run server/queue-worker.ts"
|
"start:worker": "NODE_ENV=production bun run server/queue-worker.ts"
|
||||||
},
|
},
|
||||||
|
@ -19,20 +19,27 @@ app.onError((err, c) => {
|
|||||||
// Allow all origin on development
|
// Allow all origin on development
|
||||||
if (__DEV) {
|
if (__DEV) {
|
||||||
app.use(cors({ origin: "*" }));
|
app.use(cors({ origin: "*" }));
|
||||||
|
} else {
|
||||||
|
app.use(httpLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Health check
|
// Health check
|
||||||
app.get("/health", (c) => c.text("OK"));
|
app.get("/health", (c) => c.text("OK"));
|
||||||
|
|
||||||
// Serve prod client app
|
|
||||||
if (__PROD) {
|
|
||||||
app.use(httpLogger());
|
|
||||||
app.use(serveStatic({ root: "./dist/client" }));
|
|
||||||
}
|
|
||||||
|
|
||||||
// API router
|
// API router
|
||||||
app.route("/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({
|
Bun.serve({
|
||||||
fetch: app.fetch,
|
fetch: app.fetch,
|
||||||
hostname: HOST,
|
hostname: HOST,
|
||||||
|
@ -11,10 +11,6 @@ export default defineConfig({
|
|||||||
"@server": path.resolve(__dirname, "./server"),
|
"@server": path.resolve(__dirname, "./server"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
|
||||||
outDir: "dist/client",
|
|
||||||
emptyOutDir: true,
|
|
||||||
},
|
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api": process.env.API_BASEURL || "http://127.0.0.1:5589",
|
"/api": process.env.API_BASEURL || "http://127.0.0.1:5589",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user