The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add CORS support to links API
Kiran Ke61c460f7a06
diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.tsindex e8ddfc7f51..c296e51e40 100644--- a/apps/web/app/api/links/route.ts+++ b/apps/web/app/api/links/route.ts@@ -15,6 +15,13 @@ import { LOCALHOST_IP, getSearchParamsWithArray } from "@dub/utils";import { waitUntil } from "@vercel/functions";import { NextResponse } from "next/server";+const CORS_HEADERS = {+ "Access-Control-Allow-Origin": "*",+ "Access-Control-Allow-Methods": "POST, OPTIONS",+ "Access-Control-Allow-Headers":+ "Content-Type, Authorization, dub-anonymous-link-creation",+};+// GET /api/links – get all links for a workspaceexport const GET = withWorkspace(async ({ req, headers, workspace }) => {@@ -99,3 +106,10 @@ export const POST = withWorkspace(requiredPermissions: ["links.write"],},);++export const OPTIONS = () => {+ return new Response(null, {+ status: 204,+ headers: CORS_HEADERS,+ });+};