fix: parse websocket url (#2644)
This commit is contained in:
parent
6a7240816e
commit
0d47c512d2
@ -8,6 +8,10 @@ export const getWebSocketURL = () => {
|
|||||||
const subApp = getSubAppName();
|
const subApp = getSubAppName();
|
||||||
const queryString = subApp ? `?__appName=${subApp}` : '';
|
const queryString = subApp ? `?__appName=${subApp}` : '';
|
||||||
if (process.env.WEBSOCKET_URL) {
|
if (process.env.WEBSOCKET_URL) {
|
||||||
|
const url = new URL(process.env.WEBSOCKET_URL);
|
||||||
|
if (url.hostname === 'localhost') {
|
||||||
|
return `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.hostname}:${url.port}/ws${queryString}`;
|
||||||
|
}
|
||||||
return `${process.env.WEBSOCKET_URL}${queryString}`;
|
return `${process.env.WEBSOCKET_URL}${queryString}`;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user