Skip to content

Commit

Permalink
Fix default setting for the api server
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bjoernricks committed Apr 25, 2024
1 parent ede757e commit 17dd7a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/gmp/__tests__/gmpsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const createStorage = state => {

describe('GmpSettings tests', () => {
beforeAll(() => {
global.location = {protocol: 'http:'};
global.location = {protocol: 'http:', host: 'localhost:9392'};
});

afterAll(() => {
Expand Down
3 changes: 1 addition & 2 deletions src/gmp/gmpsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -109,7 +108,7 @@ class GmpSettings {
apiProtocol = global.location.protocol;
}
if (!isDefined(apiServer)) {
apiServer = DEFAULT_API_SERVER;
apiServer = global.location.host;
}

this.logLevel = logLevel;
Expand Down

0 comments on commit 17dd7a6

Please sign in to comment.