1 parent ad289f9 commit 9b8e77eCopy full SHA for 9b8e77e
1 file changed
src/tunnel/index.js
@@ -57,6 +57,14 @@ export async function tunnelPlugin(fastify, options = {}) {
57
fastify.get(wsPath, { websocket: true }, async (connection, request) => {
58
const socket = connection.socket;
59
60
+ // Browser WebSockets can't set an Authorization header, so accept the
61
+ // bearer token as a ?token= query param too — mirrors the /.webrtc
62
+ // endpoint. Lets browser-based tunnel clients authenticate. (#528)
63
+ const queryToken = request.query?.token;
64
+ if (queryToken && !request.headers.authorization) {
65
+ request.headers.authorization = `Bearer ${queryToken}`;
66
+ }
67
+
68
// Authenticate
69
const { webId } = await getWebIdFromRequestAsync(request);
70
if (!webId) {
0 commit comments