From ae4c201e40cef3a5ff54aa6787dcd597e1a9d346 Mon Sep 17 00:00:00 2001 From: DarkSky <25152247+darkskygit@users.noreply.github.com> Date: Wed, 13 Dec 2023 21:58:22 +0800 Subject: [PATCH] fix: use secure websocket (#5297) --- .../workspace/src/providers/utils/affine-io.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/frontend/workspace/src/providers/utils/affine-io.ts b/packages/frontend/workspace/src/providers/utils/affine-io.ts index 297932ea1f..b3d4afb630 100644 --- a/packages/frontend/workspace/src/providers/utils/affine-io.ts +++ b/packages/frontend/workspace/src/providers/utils/affine-io.ts @@ -7,9 +7,16 @@ export function getIoManager(): Manager { if (ioManager) { return ioManager; } - ioManager = new Manager('/', { - autoConnect: false, - transports: ['websocket'], - }); + const { protocol, hostname, port } = window.location; + ioManager = new Manager( + `${protocol === 'https:' ? 'wss' : 'ws'}://${hostname}${ + port ? `:${port}` : '' + }/`, + { + autoConnect: false, + transports: ['websocket'], + secure: location.protocol === 'https:', + } + ); return ioManager; }