Skip to content

Commit 3b0c05e

Browse files
committed
fix: Base URL for Postgres executer
1 parent 0103327 commit 3b0c05e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/app/services/environment.service.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export class EnvService {
5959
// Local value (only if not managed instance)
6060
const localStorageValue = import.meta.env['DL_ENV_TYPE'] !== 'managed'
6161
? this.getValueFromLocalStorage(key) : null;
62-
62+
6363
// Pick value, based on priority or use fallback
6464
const value = (localStorageValue || buildtimeValue || runtimeValue) ?? fallback;
65-
65+
6666
// If nothing, and unexpected, throw error to be caught by the caller
6767
if (!value && throwError) {
6868
throw new Error(`Environment variable ${key} is not set.`);
@@ -131,9 +131,20 @@ export class EnvService {
131131
};
132132
}
133133

134+
getBaseUrl(): string {
135+
const envBase = this.getEnvVar('DL_BASE_URL', '');
136+
if (envBase) {
137+
return envBase;
138+
}
139+
if (isPlatformBrowser(this.platformId)) {
140+
return window.location.origin;
141+
}
142+
return '/';
143+
}
144+
134145
getPostgresApiUrl(): string {
135146
const endpoint = '/api/pg-executer/';
136-
const baseUrl = this.getEnvVar('DL_BASE_URL', 'http://localhost:5173');
147+
const baseUrl = this.getBaseUrl();
137148
return `${baseUrl}${endpoint}`;
138149
}
139150

0 commit comments

Comments
 (0)