Default API_BASE_URL and PROD_ORIGIN to the test environment
Previously API_BASE_URL defaulted to http://localhost:8080/api, which only works inside the dev server proxy. For standalone/SSR runs without the proxy, the default now points to https://flights.test.aeroflot.ru. Dev continues to use the same-origin proxy because scripts/dev-server.mjs explicitly injects API_BASE_URL=http://localhost:8080/api into the Modern.js child process env, keeping browser fetches CORS/WAF safe.
This commit is contained in:
+14
-2
@@ -25,11 +25,23 @@ const modernBin = resolve("node_modules", ".bin", "modern");
|
||||
const modernProcess = existsSync(modernBin)
|
||||
? spawn(modernBin, ["dev"], {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, PORT: String(MODERNJS_PORT) },
|
||||
env: {
|
||||
...process.env,
|
||||
PORT: String(MODERNJS_PORT),
|
||||
// Point the browser bundle at the same-origin proxy so CORS/WAF stay
|
||||
// bypassed. The proxy (this file) forwards to API_TARGET via curl.
|
||||
API_BASE_URL: process.env.API_BASE_URL ?? "http://localhost:8080/api",
|
||||
},
|
||||
})
|
||||
: spawn(process.execPath, [resolve("node_modules", "@modern-js/app-tools", "bin", "modern.js"), "dev"], {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, PORT: String(MODERNJS_PORT) },
|
||||
env: {
|
||||
...process.env,
|
||||
PORT: String(MODERNJS_PORT),
|
||||
// Point the browser bundle at the same-origin proxy so CORS/WAF stay
|
||||
// bypassed. The proxy (this file) forwards to API_TARGET via curl.
|
||||
API_BASE_URL: process.env.API_BASE_URL ?? "http://localhost:8080/api",
|
||||
},
|
||||
});
|
||||
modernProcess.on("error", (err) => {
|
||||
console.error("Modern.js failed:", err);
|
||||
|
||||
Reference in New Issue
Block a user