From c1aa23aca9ac88125b34e24f155c577ef5fad39c Mon Sep 17 00:00:00 2001 From: Vijay A Date: Thu, 5 Aug 2021 15:03:07 +0530 Subject: fix: change all occurrences of hard-coded ip address '127.0.0.1' to 'localhost' Also refactored to make this a constant defined in a single file where it is imported for all other uses. fixes #1253 --- src/internal-server/app/Controllers/Http/ServiceController.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/internal-server/app/Controllers/Http/ServiceController.js') diff --git a/src/internal-server/app/Controllers/Http/ServiceController.js b/src/internal-server/app/Controllers/Http/ServiceController.js index c30e9e040..e4a7f0295 100644 --- a/src/internal-server/app/Controllers/Http/ServiceController.js +++ b/src/internal-server/app/Controllers/Http/ServiceController.js @@ -5,6 +5,10 @@ const Env = use('Env'); const uuid = require('uuid/v4'); const path = require('path'); const fs = require('fs-extra'); +const { LOCAL_HOSTNAME } = require('../../../../config'); + +const hostname = LOCAL_HOSTNAME; +const port = Env.get('PORT'); class ServiceController { // Create a new service for user @@ -84,7 +88,7 @@ class ServiceController { workspaces: [], ...JSON.parse(service.settings), iconUrl: settings.iconId - ? `http://127.0.0.1:${Env.get('PORT')}/v1/icon/${settings.iconId}` + ? `http://${hostname}:${port}/v1/icon/${settings.iconId}` : null, id: service.serviceId, name: service.name, @@ -152,7 +156,7 @@ class ServiceController { id, name: service.name, ...newSettings, - iconUrl: `http://127.0.0.1:${Env.get('PORT')}/v1/icon/${ + iconUrl: `http://${hostname}:${port}/v1/icon/${ newSettings.iconId }`, userId: 1, @@ -258,7 +262,7 @@ class ServiceController { workspaces: [], ...JSON.parse(service.settings), iconUrl: settings.iconId - ? `http://127.0.0.1:${Env.get('PORT')}/v1/icon/${settings.iconId}` + ? `http://${hostname}:${port}/v1/icon/${settings.iconId}` : null, id: service.serviceId, name: service.name, -- cgit v1.2.3-54-g00ecf