From d4001e45286f0a50b6df4a8a2955f18822273978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Thu, 29 Aug 2024 20:01:00 +0200 Subject: [PATCH] fix(api/websocket): fix auth and termination --- apps/api/src/controllers/auth.ts | 3 ++- apps/api/src/controllers/v1/crawl-status-ws.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts index 0aee6db..5df6a85 100644 --- a/apps/api/src/controllers/auth.ts +++ b/apps/api/src/controllers/auth.ts @@ -104,7 +104,8 @@ export async function supaAuthenticateUser( status?: number; plan?: PlanType; }> { - const authHeader = req.headers.authorization; + console.log(req.headers); + const authHeader = req.headers.authorization ?? (req.headers["sec-websocket-protocol"] ? `Bearer ${req.headers["sec-websocket-protocol"]}` : null); if (!authHeader) { return { success: false, error: "Unauthorized", status: 401 }; } diff --git a/apps/api/src/controllers/v1/crawl-status-ws.ts b/apps/api/src/controllers/v1/crawl-status-ws.ts index 551948d..8d82309 100644 --- a/apps/api/src/controllers/v1/crawl-status-ws.ts +++ b/apps/api/src/controllers/v1/crawl-status-ws.ts @@ -85,6 +85,8 @@ async function crawlStatusWS(ws: WebSocket, req: RequestWithAuth