From 746d10cd3e4d5851efa671c3eb017f5de81f45df Mon Sep 17 00:00:00 2001 From: Fraser Steel <81355664+f-steel@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:43:28 +0000 Subject: [PATCH] feat: changing port number --- package.json | 4 ++-- src/_components/Editor/Editor.tsx | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index e8bb0cf..77b9319 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "dev:spotlight": "spotlight-sidecar", "dev:next": "next dev", "dev": "run-p dev:*", - "dev-colab": "node server.js && HOST=0.0.0.0 npx y-websocket", + "dev-colab": "node server.js", "build": "next build", "build-with-migrate": "npm run db:migrate && next build", - "start": "NODE_ENV=production node server.js && HOST=0.0.0.0 npx y-websocket", + "start": "NODE_ENV=production node server.js", "build-stats": "cross-env ANALYZE=true npm run build", "clean": "rimraf .next .swc out coverage", "lint": "next lint", diff --git a/src/_components/Editor/Editor.tsx b/src/_components/Editor/Editor.tsx index 26c5150..ddefdc3 100644 --- a/src/_components/Editor/Editor.tsx +++ b/src/_components/Editor/Editor.tsx @@ -255,8 +255,6 @@ const Editor = React.memo(function EditorC({ id={colabID} // @ts-ignore providerFactory={(id, yjsDocMap) => { - const protocol = - window.location.protocol === 'https:' ? 'wss:' : 'ws:'; let doc = yjsDocMap.get(id); if (!doc) { doc = new Y.Doc(); @@ -265,16 +263,17 @@ const Editor = React.memo(function EditorC({ doc.load(); } - // web socket provider - const url = new URL(window.location.href); - const wsUrl = - window.location.protocol === 'https' - ? 'wss://socket.wetype.net' - : `${protocol}//${url.hostname}:1234/socket.io`; + const protocol = + window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const provider = new WebsocketProvider(wsUrl, id, doc, { - connect: true, - }); + const provider = new WebsocketProvider( + `${protocol}//${window.location.host}/socket.io`, + id, + doc, + { + connect: true, + } + ); provider.on('status', (event: { status: string }) => { // logger.debug(event.status);