Skip to content

Commit c8679e4

Browse files
committed
env var for port
1 parent 11a6c35 commit c8679e4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/app-pages-router/proxy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ import { spawn } from "node:child_process";
33
import express from "express";
44
import proxy from "express-http-proxy";
55

6-
const PORT = 3002;
6+
const PORT = process.env.PORT ?? 3000;
77

88
// Start servers
99
spawn("node", [".open-next/server-functions/default/index.mjs"], {
10-
env: { ...process.env, PORT: "3003" },
10+
env: { ...process.env, PORT: "3010" },
1111
stdio: "inherit",
1212
});
1313

1414
spawn("node", [".open-next/server-functions/api/index.mjs"], {
15-
env: { ...process.env, PORT: "3004" },
15+
env: { ...process.env, PORT: "3011" },
1616
stdio: "inherit",
1717
});
1818

1919
const app = express();
2020

2121
app.use(
2222
"/api/*",
23-
proxy("http://localhost:3004", {
23+
proxy("http://localhost:3011", {
2424
proxyReqPathResolver: (req) => req.originalUrl,
2525
proxyReqOptDecorator: (proxyReqOpts) => {
2626
proxyReqOpts.headers.host = `localhost:${PORT}`;
@@ -32,12 +32,12 @@ app.use(
3232
// Catch-all for everything else
3333
app.use(
3434
"*",
35-
proxy("http://localhost:3003", {
35+
proxy("http://localhost:3010", {
3636
proxyReqPathResolver: (req) => req.originalUrl,
3737
proxyReqOptDecorator: (proxyReqOpts) => {
3838
// We need to ensure the host header is set correctly else you will run into this error in `/server-actions`
3939
// Error: Invalid Server Actions request:
40-
// `x-forwarded-host` header with value `localhost:3003` does not match `origin` header with value `localhost:3002` from a forwarded Server Actions request. Aborting the action.
40+
// `x-forwarded-host` header with value `localhost:3010` does not match `origin` header with value `localhost:3000` from a forwarded Server Actions request. Aborting the action.
4141
proxyReqOpts.headers.host = `localhost:${PORT}`;
4242
delete proxyReqOpts.headers["x-forwarded-host"];
4343
return proxyReqOpts;

0 commit comments

Comments
 (0)