From 52845da8328ddbf436157be0b4b7c10871f14f6e Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Thu, 7 May 2026 21:20:31 +0700 Subject: [PATCH] fix: update proxy configuration to use 'config' export and move allowed methods inside handler --- pages/api/proxy.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pages/api/proxy.ts b/pages/api/proxy.ts index 920742e..ee6fe4c 100644 --- a/pages/api/proxy.ts +++ b/pages/api/proxy.ts @@ -6,19 +6,13 @@ import { isAllowedTarget, } from "@/lib/relay-utils"; -export const runtime = "edge"; - -const ALLOWED_METHODS = new Set(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]); - -export async function POST(req: Request) { return await handler(req); } -export async function GET(req: Request) { return await handler(req); } -export async function PUT(req: Request) { return await handler(req); } -export async function DELETE(req: Request) { return await handler(req); } -export async function PATCH(req: Request) { return await handler(req); } -export async function HEAD(req: Request) { return await handler(req); } -export async function OPTIONS(req: Request) { return await handler(req); } +export const config = { + runtime: 'edge', +}; async function handler(req: Request): Promise { + const ALLOWED_METHODS = new Set(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]); + if (!ALLOWED_METHODS.has(req.method)) { return new Response(JSON.stringify({ error: "Method not allowed" }), { status: 405, @@ -56,3 +50,5 @@ async function handler(req: Request): Promise { const response = await fetch(targetUrl, fetchOptions); return createRelayResponse(response); } + +export default handler;