fix: parse websocket url (#2644)

This commit is contained in:
chenos 2023-09-13 18:28:28 +08:00
parent 6a7240816e
commit 0d47c512d2

View File

@ -8,6 +8,10 @@ export const getWebSocketURL = () => {
const subApp = getSubAppName();
const queryString = subApp ? `?__appName=${subApp}` : '';
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}`;
}
try {