Skip to content

Commit ae1f924

Browse files
fix: Prioritize dynamic backend port for API base URL in local env
Co-authored-by: aider (vertex_ai/gemini-2.5-flash) <aider@aider.chat>
1 parent e6c22ab commit ae1f924

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

frontend/scripts/env.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@ function generateEnvironmentFile() {
1010
hydrateProcessEnv();
1111

1212
const backendPort = determineBackendPort();
13-
const resolvedApiBase = process.env.API_BASE_URL || (backendPort ? `http://localhost:${backendPort}/api/` : 'http://localhost:3000/api/');
13+
14+
let resolvedApiBase;
15+
// When running locally, we must prioritize the dynamic backend port over any
16+
// value from a .env file, which likely contains the default port.
17+
if (backendPort) {
18+
resolvedApiBase = `http://localhost:${backendPort}/api/`;
19+
}
20+
// For other cases (like CI builds), use the environment variable or a fallback.
21+
else {
22+
resolvedApiBase =
23+
process.env.API_BASE_URL || 'http://localhost:3000/api/';
24+
}
25+
1426
const frontPort = determineFrontendPort();
1527
const resolvedUiUrl = process.env.UI_URL || `http://localhost:${frontPort ?? '4200'}/`;
1628

0 commit comments

Comments
 (0)