Skip to content

Commit e4116e1

Browse files
committed
fix: use env vars for api proxy ports with correct defaults
- API_V1_PORT defaults to 3000 (matching web's default) - API_V2_PORT defaults to 5555 (matching api-v2's default) - API_PROXY_PORT defaults to 3002 - Fixed route order: /v2 before / to prevent catch-all
1 parent d9f2e09 commit e4116e1

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

apps/api/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ const http = require("node:http");
22
const connect = require("connect");
33
const { createProxyMiddleware } = require("http-proxy-middleware");
44

5+
const API_V1_PORT = process.env.API_V1_PORT || 3000;
6+
const API_V2_PORT = process.env.API_V2_PORT || 5555;
7+
const PROXY_PORT = process.env.API_PROXY_PORT || 3002;
8+
59
const apiProxyV1 = createProxyMiddleware({
6-
target: "http://localhost:3003",
10+
target: `http://localhost:${API_V1_PORT}`,
711
});
812

913
const apiProxyV2 = createProxyMiddleware({
10-
target: "http://localhost:3004",
14+
target: `http://localhost:${API_V2_PORT}`,
1115
});
1216

1317
const app = connect();
14-
app.use("/", apiProxyV1);
15-
1618
app.use("/v2", apiProxyV2);
19+
app.use("/", apiProxyV1);
1720

18-
http.createServer(app).listen(3002);
21+
http.createServer(app).listen(PROXY_PORT);

0 commit comments

Comments
 (0)