Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

CORS_HEADERS

Steven Tey7e425b1f4d62
diff --git a/apps/web/app/api/track/click/route.ts b/apps/web/app/api/track/click/route.ts
index 1930244b57..d2f5fc9ee8 100644
--- a/apps/web/app/api/track/click/route.ts
+++ b/apps/web/app/api/track/click/route.ts
@@ -12,6 +12,12 @@ import { NextResponse } from "next/server";
export const runtime = "edge";
+const CORS_HEADERS = {
+ "Access-Control-Allow-Origin": "*",
+ "Access-Control-Allow-Methods": "POST, OPTIONS",
+ "Access-Control-Allow-Headers": "Content-Type, Authorization",
+};
+
// POST /api/track/click – Track a click event from client side
export const POST = async (req: Request) => {
try {
@@ -63,9 +69,7 @@ export const POST = async (req: Request) => {
clickId,
},
{
- headers: {
- "Access-Control-Allow-Origin": "*",
- },
+ headers: CORS_HEADERS,
},
);
} catch (error) {
@@ -76,10 +80,6 @@ export const POST = async (req: Request) => {
export const OPTIONS = () => {
return new Response(null, {
status: 204,
- headers: {
- "Access-Control-Allow-Origin": "*",
- "Access-Control-Allow-Methods": "POST, OPTIONS",
- "Access-Control-Allow-Headers": "Content-Type, Authorization",
- },
+ headers: CORS_HEADERS,
});
};