From b624461f0dfe4194f60fb87cdc445dc4b30155f2 Mon Sep 17 00:00:00 2001 From: SevenWaysDP Date: Mon, 22 Jul 2024 10:28:51 +0200 Subject: [PATCH] chore: Add WS_PATH_PREFIX to configmap.yml.j2 and server.js --- ansible/roles/tldraw-server/templates/configmap.yml.j2 | 1 + src/server.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ansible/roles/tldraw-server/templates/configmap.yml.j2 b/ansible/roles/tldraw-server/templates/configmap.yml.j2 index 0aca9508..b46e4cb9 100644 --- a/ansible/roles/tldraw-server/templates/configmap.yml.j2 +++ b/ansible/roles/tldraw-server/templates/configmap.yml.j2 @@ -7,3 +7,4 @@ metadata: app: tldraw-server data: API_HOST: "http://api-svc:3030" + WS_PATH_PREFIX: "/tldraw-server" \ No newline at end of file diff --git a/src/server.js b/src/server.js index 5f882bf3..35d031f6 100644 --- a/src/server.js +++ b/src/server.js @@ -11,6 +11,7 @@ import * as uws from 'uws' import { initStorage } from './storage.js' const apiHost = env.getConf('api-host') || 'http://localhost:3030'; +const wsPathPrefix = env.getConf('ws-path-prefix') || ''; /** * @@ -70,7 +71,7 @@ export const createYWebsocketServer = async ({ }) => { const app = uws.App({}) - await registerYWebsocketServer(app, '/:room', store, async (req) => { + await registerYWebsocketServer(app, `${wsPathPrefix}/:room`, store, async (req) => { const room = req.getParameter(0) const headerWsProtocol = req.getHeader('sec-websocket-protocol') const [, , token] = /(^|,)yauth-(((?!,).)*)/.exec(headerWsProtocol) ?? [null, null, req.getQuery('yauth')]