mirror of
https://github.com/Xevion/xevion.dev.git
synced 2025-12-05 23:16:57 -06:00
Allow passing CRON_SECRET via query parameter, use production only, don't return response directly
This commit is contained in:
@@ -200,12 +200,15 @@ export default async function handler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the cron request is authenticated
|
// Ensure the cron request is authenticated
|
||||||
if (process.env.NODE_ENV !== "development") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
const authHeader = req.headers["authorization"];
|
const authHeader = req.headers["authorization"];
|
||||||
if (authHeader !== `Bearer ${CRON_SECRET}`) {
|
const secretQueryParam = req.query.secret;
|
||||||
return new Response("Unauthorized", {
|
if (
|
||||||
status: 401,
|
authHeader !== `Bearer ${CRON_SECRET}` &&
|
||||||
});
|
secretQueryParam !== CRON_SECRET
|
||||||
|
) {
|
||||||
|
res.status(401).json({ error: "Unauthorized" });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user