From e3b48a6f6565f4b85e6d41ced3894d02ce50b55f Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Fri, 22 Nov 2024 08:06:41 -0500 Subject: [PATCH] use environments --- client/admin/angular.json | 8 +++++++- client/admin/src/app/app.config.ts | 9 ++------- client/admin/src/environments/environment.development.ts | 3 +++ client/admin/src/environments/environment.ts | 3 +++ 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 client/admin/src/environments/environment.development.ts create mode 100644 client/admin/src/environments/environment.ts diff --git a/client/admin/angular.json b/client/admin/angular.json index 6943477..8cc1fdd 100644 --- a/client/admin/angular.json +++ b/client/admin/angular.json @@ -46,7 +46,13 @@ "development": { "optimization": false, "extractLicenses": false, - "sourceMap": true + "sourceMap": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.development.ts" + } + ] } }, "defaultConfiguration": "production" diff --git a/client/admin/src/app/app.config.ts b/client/admin/src/app/app.config.ts index 74fe6e8..5c4a112 100644 --- a/client/admin/src/app/app.config.ts +++ b/client/admin/src/app/app.config.ts @@ -1,5 +1,6 @@ import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; import { provideRouter } from '@angular/router'; +import { environment } from './../environments/environment'; import { HttpRequest, HttpHandlerFn, @@ -12,17 +13,11 @@ import { AuthService } from './login/auth.service'; import { routes } from './app.routes'; import { provideHttpClient } from '@angular/common/http'; - export function apiBaseInterceptor( req: HttpRequest, next: HttpHandlerFn, ): Observable> { - let baseUrl: string; - if (isDevMode()) { - baseUrl = 'http://xenon:3050'; - } else { - baseUrl = ''; - } + let baseUrl = environment.baseUrl; const apiReq = req.clone({ url: `${baseUrl}${req.url}` }); return next(apiReq); } diff --git a/client/admin/src/environments/environment.development.ts b/client/admin/src/environments/environment.development.ts new file mode 100644 index 0000000..247eb12 --- /dev/null +++ b/client/admin/src/environments/environment.development.ts @@ -0,0 +1,3 @@ +export const environment = { + baseUrl: 'http://xenon:3050', +}; diff --git a/client/admin/src/environments/environment.ts b/client/admin/src/environments/environment.ts new file mode 100644 index 0000000..e67cb31 --- /dev/null +++ b/client/admin/src/environments/environment.ts @@ -0,0 +1,3 @@ +export const environment = { + baseUrl: '', +};