From 17dd7a6e489d0d4e1189b006b9af70ba0e686de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Thu, 25 Apr 2024 15:09:54 +0200 Subject: [PATCH] Fix default setting for the api server The api server must be determined from the current host. Otherwise it all ajax requests would go to localhost:9292 by default and it would be required to set the correct host name in the config.js for every installation. --- src/gmp/__tests__/gmpsettings.js | 2 +- src/gmp/gmpsettings.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gmp/__tests__/gmpsettings.js b/src/gmp/__tests__/gmpsettings.js index c832e886dd..e13f1c3329 100644 --- a/src/gmp/__tests__/gmpsettings.js +++ b/src/gmp/__tests__/gmpsettings.js @@ -37,7 +37,7 @@ const createStorage = state => { describe('GmpSettings tests', () => { beforeAll(() => { - global.location = {protocol: 'http:'}; + global.location = {protocol: 'http:', host: 'localhost:9392'}; }); afterAll(() => { diff --git a/src/gmp/gmpsettings.js b/src/gmp/gmpsettings.js index b4a03d1255..e2f6dc4d6d 100644 --- a/src/gmp/gmpsettings.js +++ b/src/gmp/gmpsettings.js @@ -26,7 +26,6 @@ export const DEFAULT_PROTOCOLDOC_URL = `https://docs.greenbone.net/API/GMP/gmp-2 export const DEFAULT_REPORT_RESULTS_THRESHOLD = 25000; export const DEFAULT_LOG_LEVEL = 'warn'; export const DEFAULT_TIMEOUT = 300000; // 5 minutes -export const DEFAULT_API_SERVER = 'localhost:9392'; const set = (storage, name, value) => { if (isDefined(value)) { @@ -109,7 +108,7 @@ class GmpSettings { apiProtocol = global.location.protocol; } if (!isDefined(apiServer)) { - apiServer = DEFAULT_API_SERVER; + apiServer = global.location.host; } this.logLevel = logLevel;