The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix usage cron again
Steven Teydf404a5ee663
diff --git a/apps/web/app/api/cron/usage/route.ts b/apps/web/app/api/cron/usage/route.tsindex 83500b0705..5cd3a55c14 100644--- a/apps/web/app/api/cron/usage/route.ts+++ b/apps/web/app/api/cron/usage/route.ts@@ -10,13 +10,16 @@ import { updateUsage } from "./utils";export const dynamic = "force-dynamic";-export async function GET(req: Request) {+async function handler(req: Request) {try {- await verifyVercelSignature(req);- const body = await req.json();- await verifyQstashSignature(req, body);+ if (req.method === "GET") {+ await verifyVercelSignature(req);+ } else if (req.method === "POST") {+ await verifyQstashSignature(req);+ }await updateUsage();+return NextResponse.json({response: "success",});@@ -29,3 +32,5 @@ export async function GET(req: Request) {return handleAndReturnErrorResponse(error);}}++export { handler as GET, handler as POST };diff --git a/apps/web/app/api/cron/usage/utils.ts b/apps/web/app/api/cron/usage/utils.tsindex 0f3ba387d1..494bf6643c 100644--- a/apps/web/app/api/cron/usage/utils.ts+++ b/apps/web/app/api/cron/usage/utils.ts@@ -241,6 +241,7 @@ export const updateUsage = async () => {return await qstash.publishJSON({url: `${APP_DOMAIN_WITH_NGROK}/api/cron/usage`,- method: "GET",+ method: "POST",+ body: {},});};diff --git a/apps/web/lib/cron/verify-qstash.ts b/apps/web/lib/cron/verify-qstash.tsindex e59e762623..729a8fa499 100644--- a/apps/web/lib/cron/verify-qstash.ts+++ b/apps/web/lib/cron/verify-qstash.ts@@ -18,8 +18,6 @@ export const verifyQstashSignature = async (body: JSON.stringify(body),});- console.log({ isValid });-if (!isValid) {throw new DubApiError({code: "unauthorized",