Log a warning in the UI when falling back to default connection parameters
This commit is contained in:
@@ -43,8 +43,13 @@ export interface AuthKeyResponse {
|
|||||||
export class MetaAPI {
|
export class MetaAPI {
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
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<MetaEndpoint[]> {
|
listEndpoints(): Observable<MetaEndpoint[]> {
|
||||||
return this.http.get<MetaEndpoint[]>(`${this.httpEndpoint}/v1/endpoints`)
|
return this.http.get<MetaEndpoint[]>(`${this.httpEndpoint}/v1/endpoints`)
|
||||||
|
|||||||
@@ -47,11 +47,13 @@ export class PortmasterAPIModule {
|
|||||||
* @param cfg The module configuration defining the Portmaster HTTP and Websocket API endpoints.
|
* @param cfg The module configuration defining the Portmaster HTTP and Websocket API endpoints.
|
||||||
*/
|
*/
|
||||||
static forRoot(cfg: ModuleConfig = {}): ModuleWithProviders<PortmasterAPIModule> {
|
static forRoot(cfg: ModuleConfig = {}): ModuleWithProviders<PortmasterAPIModule> {
|
||||||
if (cfg.httpAPI === undefined) {
|
if (!cfg.httpAPI) {
|
||||||
cfg.httpAPI = `http://127.0.0.1:817/api`;
|
cfg.httpAPI = `http://${window.location.host}/api`;
|
||||||
|
console.warn("[portmaster-api] No HTTP API endpoint provided, using default: " + cfg.httpAPI);
|
||||||
}
|
}
|
||||||
if (cfg.websocketAPI === undefined) {
|
if (!cfg.websocketAPI) {
|
||||||
cfg.websocketAPI = `ws://127.0.0.1:817/api/database/v1`;
|
cfg.websocketAPI = `ws://${window.location.host}/api/database/v1`;
|
||||||
|
console.warn("[portmaster-api] No WebSocket API endpoint provided, using default: " + cfg.websocketAPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
export const environment = new class {
|
export const environment = {
|
||||||
readonly supportHub = "https://support.safing.io"
|
production: true,
|
||||||
readonly production = true;
|
portAPI: `ws://${window.location.host}/api/database/v1`,
|
||||||
|
httpAPI: `http://${window.location.host}/api`,
|
||||||
get httpAPI() {
|
supportHub: "https://support.safing.io"
|
||||||
return `http://${window.location.host}/api`
|
};
|
||||||
}
|
|
||||||
|
|
||||||
get portAPI() {
|
|
||||||
const result = `ws://${window.location.host}/api/database/v1`;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -76,12 +76,13 @@ if (location.pathname !== "/prompt") {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// bootstrap the prompt interface
|
// bootstrap the prompt interface
|
||||||
|
console.log("[INFO] Bootstrapping prompt entry point.");
|
||||||
bootstrapApplication(PromptEntryPointComponent, {
|
bootstrapApplication(PromptEntryPointComponent, {
|
||||||
providers: [
|
providers: [
|
||||||
provideHttpClient(),
|
provideHttpClient(),
|
||||||
importProvidersFrom(PortmasterAPIModule.forRoot({
|
importProvidersFrom(PortmasterAPIModule.forRoot({
|
||||||
websocketAPI: "ws://127.0.0.1:817/api/database/v1",
|
websocketAPI: "ws://localhost:817/api/database/v1",
|
||||||
httpAPI: "http://127.0.0.1:817/api"
|
httpAPI: "http://localhost:817/api"
|
||||||
})),
|
})),
|
||||||
NotificationsService,
|
NotificationsService,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user