diff --git a/desktop/angular/projects/safing/portmaster-api/src/lib/meta-api.service.ts b/desktop/angular/projects/safing/portmaster-api/src/lib/meta-api.service.ts index 8063a431..313ea127 100644 --- a/desktop/angular/projects/safing/portmaster-api/src/lib/meta-api.service.ts +++ b/desktop/angular/projects/safing/portmaster-api/src/lib/meta-api.service.ts @@ -43,8 +43,13 @@ export interface AuthKeyResponse { export class MetaAPI { constructor( private http: HttpClient, - @Inject(PORTMASTER_HTTP_API_ENDPOINT) @Optional() private httpEndpoint: string = 'http://127.0.0.1:817/api', - ) { } + @Inject(PORTMASTER_HTTP_API_ENDPOINT) @Optional() private httpEndpoint: string, + ) { + if (!this.httpEndpoint) { + this.httpEndpoint = `http://localhost:817/api`; + console.warn("[portmaster-api: MetaAPI] No HTTP API endpoint provided, using default: " + this.httpEndpoint); + } + } listEndpoints(): Observable { return this.http.get(`${this.httpEndpoint}/v1/endpoints`) diff --git a/desktop/angular/projects/safing/portmaster-api/src/lib/module.ts b/desktop/angular/projects/safing/portmaster-api/src/lib/module.ts index 076b390d..13d5e048 100644 --- a/desktop/angular/projects/safing/portmaster-api/src/lib/module.ts +++ b/desktop/angular/projects/safing/portmaster-api/src/lib/module.ts @@ -47,11 +47,13 @@ export class PortmasterAPIModule { * @param cfg The module configuration defining the Portmaster HTTP and Websocket API endpoints. */ static forRoot(cfg: ModuleConfig = {}): ModuleWithProviders { - if (cfg.httpAPI === undefined) { - cfg.httpAPI = `http://127.0.0.1:817/api`; + if (!cfg.httpAPI) { + cfg.httpAPI = `http://${window.location.host}/api`; + console.warn("[portmaster-api] No HTTP API endpoint provided, using default: " + cfg.httpAPI); } - if (cfg.websocketAPI === undefined) { - cfg.websocketAPI = `ws://127.0.0.1:817/api/database/v1`; + if (!cfg.websocketAPI) { + cfg.websocketAPI = `ws://${window.location.host}/api/database/v1`; + console.warn("[portmaster-api] No WebSocket API endpoint provided, using default: " + cfg.websocketAPI); } return { diff --git a/desktop/angular/src/environments/environment.prod.ts b/desktop/angular/src/environments/environment.prod.ts index 8cdffedb..ecca4342 100644 --- a/desktop/angular/src/environments/environment.prod.ts +++ b/desktop/angular/src/environments/environment.prod.ts @@ -1,13 +1,6 @@ -export const environment = new class { - readonly supportHub = "https://support.safing.io" - readonly production = true; - - get httpAPI() { - return `http://${window.location.host}/api` - } - - get portAPI() { - const result = `ws://${window.location.host}/api/database/v1`; - return result; - } -} \ No newline at end of file +export const environment = { + production: true, + portAPI: `ws://${window.location.host}/api/database/v1`, + httpAPI: `http://${window.location.host}/api`, + supportHub: "https://support.safing.io" +}; \ No newline at end of file diff --git a/desktop/angular/src/main.ts b/desktop/angular/src/main.ts index c62691ce..d4a8424c 100644 --- a/desktop/angular/src/main.ts +++ b/desktop/angular/src/main.ts @@ -76,12 +76,13 @@ if (location.pathname !== "/prompt") { } else { // bootstrap the prompt interface + console.log("[INFO] Bootstrapping prompt entry point."); bootstrapApplication(PromptEntryPointComponent, { providers: [ provideHttpClient(), importProvidersFrom(PortmasterAPIModule.forRoot({ - websocketAPI: "ws://127.0.0.1:817/api/database/v1", - httpAPI: "http://127.0.0.1:817/api" + websocketAPI: "ws://localhost:817/api/database/v1", + httpAPI: "http://localhost:817/api" })), NotificationsService, {