mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-03 05:02:33 +03:00
fix: websocket prefix (#5372)
This commit is contained in:
parent
ec7f73f168
commit
06912c6885
@ -2,21 +2,25 @@ import { Manager } from 'socket.io-client';
|
||||
|
||||
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
|
||||
export function getIoManager(): Manager {
|
||||
if (ioManager) {
|
||||
return ioManager;
|
||||
}
|
||||
const { protocol, hostname, port } = window.location;
|
||||
ioManager = new Manager(
|
||||
`${protocol === 'https:' ? 'wss' : 'ws'}://${hostname}${
|
||||
port ? `:${port}` : ''
|
||||
}/`,
|
||||
{
|
||||
autoConnect: false,
|
||||
transports: ['websocket'],
|
||||
secure: location.protocol === 'https:',
|
||||
}
|
||||
);
|
||||
ioManager = new Manager(`${getBaseUrl()}/`, {
|
||||
autoConnect: false,
|
||||
transports: ['websocket'],
|
||||
secure: location.protocol === 'https:',
|
||||
});
|
||||
return ioManager;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user