fix(api/websocket): fix auth and termination

This commit is contained in:
Gergő Móricz 2024-08-29 20:01:00 +02:00
parent 1174bc3c82
commit d4001e4528
2 changed files with 4 additions and 1 deletions

View File

@ -104,7 +104,8 @@ export async function supaAuthenticateUser(
status?: number; status?: number;
plan?: PlanType; 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) { if (!authHeader) {
return { success: false, error: "Unauthorized", status: 401 }; return { success: false, error: "Unauthorized", status: 401 };
} }

View File

@ -85,6 +85,8 @@ async function crawlStatusWS(ws: WebSocket, req: RequestWithAuth<CrawlStatusPara
} }
} }
doneJobIDs.push(...newlyDoneJobIDs);
setTimeout(loop, 1000); setTimeout(loop, 1000);
}; };