mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix: websocket prefix (#5372)
This commit is contained in:
@@ -2,21 +2,25 @@ import { Manager } from 'socket.io-client';
|
|||||||
|
|
||||||
let ioManager: Manager | null = null;
|
let ioManager: Manager | null = null;
|
||||||
|
|
||||||
|
function getBaseUrl(): string {
|
||||||
|
if (environment.isDesktop) {
|
||||||
|
return runtimeConfig.serverUrlPrefix;
|
||||||
|
}
|
||||||
|
const { protocol, hostname, port } = window.location;
|
||||||
|
return `${protocol === 'https:' ? 'wss' : 'ws'}://${hostname}${
|
||||||
|
port ? `:${port}` : ''
|
||||||
|
}`;
|
||||||
|
}
|
||||||
|
|
||||||
// use lazy initialization socket.io io manager
|
// use lazy initialization socket.io io manager
|
||||||
export function getIoManager(): Manager {
|
export function getIoManager(): Manager {
|
||||||
if (ioManager) {
|
if (ioManager) {
|
||||||
return ioManager;
|
return ioManager;
|
||||||
}
|
}
|
||||||
const { protocol, hostname, port } = window.location;
|
ioManager = new Manager(`${getBaseUrl()}/`, {
|
||||||
ioManager = new Manager(
|
autoConnect: false,
|
||||||
`${protocol === 'https:' ? 'wss' : 'ws'}://${hostname}${
|
transports: ['websocket'],
|
||||||
port ? `:${port}` : ''
|
secure: location.protocol === 'https:',
|
||||||
}/`,
|
});
|
||||||
{
|
|
||||||
autoConnect: false,
|
|
||||||
transports: ['websocket'],
|
|
||||||
secure: location.protocol === 'https:',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return ioManager;
|
return ioManager;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user