0

Merge pull request #12 from mendableai/bugfix/normalized-api-on-crawl-status

[Bugfix] added normalized apikey to craw/status route
This commit is contained in:
Nicolas 2024-04-17 13:42:26 -04:00 committed by GitHub
commit c837f1cc04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -256,11 +256,13 @@ app.get("/v0/crawl/status/:jobId", async (req, res) => {
return res.status(401).json({ error: "Unauthorized: Token missing" }); 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 // make sure api key is valid, based on the api_keys table in supabase
const { data, error } = await supabase_service const { data, error } = await supabase_service
.from("api_keys") .from("api_keys")
.select("*") .select("*")
.eq("key", token); .eq("key", normalizedApi);
if (error || !data || data.length === 0) { if (error || !data || data.length === 0) {
return res.status(401).json({ error: "Unauthorized: Invalid token" }); return res.status(401).json({ error: "Unauthorized: Invalid token" });
} }