File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments