Skip to content

Commit

Permalink
chore: Add WS_PATH_PREFIX to configmap.yml.j2 and server.js
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenWaysDP committed Jul 22, 2024
1 parent b18a6bc commit b624461
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions ansible/roles/tldraw-server/templates/configmap.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ metadata:
app: tldraw-server
data:
API_HOST: "http://api-svc:3030"
WS_PATH_PREFIX: "/tldraw-server"
3 changes: 2 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') || '';

/**
*
Expand Down Expand Up @@ -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')]
Expand Down

0 comments on commit b624461

Please sign in to comment.