Remove hardcoded url & use absolute url to make requests
This commit is contained in:
parent
1e33fd0ea4
commit
d931dfc696
|
|
@ -38,8 +38,8 @@ export function listenToWebSocket() {
|
||||||
if (!getToken()) {
|
if (!getToken()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const wsUrl = config.get('url').replace('http', 'ws').replace('https', 'wss');
|
||||||
const ws = new WebSocket('ws://localhost:80/stream?token=' + getToken());
|
const ws = new WebSocket(wsUrl + 'stream?token=' + getToken());
|
||||||
|
|
||||||
ws.onerror = (e) => {
|
ws.onerror = (e) => {
|
||||||
console.log('WebSocket connection errored; trying again in 60 seconds', e);
|
console.log('WebSocket connection errored; trying again in 60 seconds', e);
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,13 @@ const defaultDevConfig = {
|
||||||
url: 'http://localhost:80/',
|
url: 'http://localhost:80/',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const {port, hostname, protocol} = window.location;
|
||||||
|
const slashes = protocol.concat('//');
|
||||||
|
const url = slashes.concat(hostname.concat(':', port));
|
||||||
|
const urlWithSlash = url.endsWith('/') ? url : url.concat('/');
|
||||||
|
|
||||||
const defaultProdConfig = {
|
const defaultProdConfig = {
|
||||||
url: './',
|
url: urlWithSlash,
|
||||||
};
|
};
|
||||||
|
|
||||||
(function clientJS() {
|
(function clientJS() {
|
||||||
|
|
@ -22,6 +27,6 @@ const defaultProdConfig = {
|
||||||
config.set(window.config || defaultDevConfig);
|
config.set(window.config || defaultDevConfig);
|
||||||
}
|
}
|
||||||
checkIfAlreadyLoggedIn();
|
checkIfAlreadyLoggedIn();
|
||||||
ReactDOM.render(<Layout />, document.getElementById('root'));
|
ReactDOM.render(<Layout/>, document.getElementById('root'));
|
||||||
registerServiceWorker();
|
registerServiceWorker();
|
||||||
}());
|
}());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue