From 25a9255c7e8d2478565ddfda60e5a725a78f9517 Mon Sep 17 00:00:00 2001 From: rafaelsideguide <150964962+rafaelsideguide@users.noreply.github.com> Date: Wed, 17 Apr 2024 12:59:49 -0300 Subject: [PATCH] [bugfix] added normalized apikey to craw/status route --- apps/api/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 7198988..0e89c6a 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -256,11 +256,13 @@ app.get("/v0/crawl/status/:jobId", async (req, res) => { return res.status(401).json({ error: "Unauthorized: Token missing" }); } + const normalizedApi = parseApi(token); // make sure api key is valid, based on the api_keys table in supabase const { data, error } = await supabase_service .from("api_keys") .select("*") - .eq("key", token); + .eq("key", normalizedApi); + if (error || !data || data.length === 0) { return res.status(401).json({ error: "Unauthorized: Invalid token" }); }