From 7ce83fca929749ad75d0c34e455a1ceacf6ef608 Mon Sep 17 00:00:00 2001 From: "Engelbart Kai Sven (PEA4-Fe)" Date: Tue, 9 Mar 2021 16:52:59 +0100 Subject: [PATCH] Use test API when running as test instance --- src/app/app.component.ts | 2 +- src/app/services/api.service.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 98054b8..ddc40d3 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -40,7 +40,7 @@ export class AppComponent implements OnInit{ ngOnInit() { // Try to log in user this.login.login().then(res => { - // Return to home page if log failed, except when on documentation pages + // Return to home page if log in failed, except when on documentation pages if (!res && !(/\/documentation/.test(this.router.url))) { this.router.navigate(['/']); } diff --git a/src/app/services/api.service.ts b/src/app/services/api.service.ts index aa79880..8947014 100644 --- a/src/app/services/api.service.ts +++ b/src/app/services/api.service.ts @@ -11,14 +11,21 @@ import {ModalService} from '@inst-iot/bosch-angular-ui-components'; }) export class ApiService { - private host = isDevMode() ? '/api' : 'https://definma-api.apps.de1.bosch-iot-cloud.com'; + private host: string; constructor( private http: HttpClient, private storage: LocalStorageService, private modalService: ModalService, private window: Window - ) { } + ) { + if(isDevMode()) + this.host = '/api'; + else if(window.location.hostname === 'definma-test.apps.de1.bosch-iot-cloud.com') + this.host = 'https://definma-api-test.apps.de1.bosch-iot-cloud.com'; + else + this.host = 'https://definma-api.apps.de1.bosch-iot-cloud.com'; + } get hostName() { return this.host;