Skip to content

Commit 0d48bc8

Browse files
committed
Ship the backend URL in config.js as the default
A build that cannot see the BACKEND_URL variable was blanking the address, which is indistinguishable from a build that never ran. The committed value now stands unless the variable overrides it.
1 parent 5103791 commit 0d48bc8

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎chat-app/front-end/config.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
// Generated at build time by scripts/inject-backend-url.mjs — do not edit.
2-
window.BACKEND_URL = "";
1+
// The deployed backend. The Netlify build can override this by setting a
2+
// BACKEND_URL environment variable; with no variable set, this value stands.
3+
window.BACKEND_URL = "https://world-chat-backend-zlha.onrender.com";

‎scripts/inject-backend-url.mjs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ if (raw && !/^https?:\/\//.test(raw)) {
1313
process.exit(1);
1414
}
1515

16+
// With no variable set, leave the committed config.js alone. It carries the
17+
// deployed backend URL, so a build that cannot see the variable still ships a
18+
// working site instead of silently blanking the address.
19+
if (!raw) {
20+
console.log("No BACKEND_URL set — keeping the committed config.js");
21+
process.exit(0);
22+
}
23+
1624
const out = new URL("../chat-app/front-end/config.js", import.meta.url);
1725

1826
writeFileSync(
@@ -21,4 +29,4 @@ writeFileSync(
2129
`window.BACKEND_URL = ${JSON.stringify(raw)};\n`
2230
);
2331

24-
console.log(raw ? `BACKEND_URL set to ${raw}` : "BACKEND_URL empty (local/same-origin mode)");
32+
console.log(`BACKEND_URL set to ${raw}`);

0 commit comments

Comments
 (0)