From f79c0872ddfcbe02a7bcc498b4a9d5d202caccd2 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sun, 9 May 2021 13:12:21 +0200 Subject: ui: Update runtime variable workaround This change updates the workaround used to access runtime variables in the React frontend, in order to improve the ergonimics when using the development mode of CRA (Create React App). --- opendc-web/opendc-web-ui/src/api/socket.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'opendc-web/opendc-web-ui/src/api/socket.js') diff --git a/opendc-web/opendc-web-ui/src/api/socket.js b/opendc-web/opendc-web-ui/src/api/socket.js index 884c4152..87facda8 100644 --- a/opendc-web/opendc-web-ui/src/api/socket.js +++ b/opendc-web/opendc-web-ui/src/api/socket.js @@ -1,5 +1,6 @@ import io from 'socket.io-client' import { getAuthToken } from '../auth/index' +import config from '../config' let socket let requestIdCounter = 0 @@ -7,8 +8,7 @@ const callbacks = {} export function setupSocketConnection(onConnect) { const apiUrl = - window.$$env['API_BASE_URL'] || - `${window.location.protocol}//${window.location.hostname}:${window.location.port}` + config['API_BASE_URL'] || `${window.location.protocol}//${window.location.hostname}:${window.location.port}` socket = io.connect(apiUrl) socket.on('connect', onConnect) -- cgit v1.2.3