From 5a6d9eeda4469affe219a0fcbcfb65c58e290a10 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Tue, 17 Mar 2026 15:32:09 +0800 Subject: [PATCH] Fix wallet delete authorization --- frontend/app/api/payments/wallets/route.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/app/api/payments/wallets/route.ts b/frontend/app/api/payments/wallets/route.ts index 05bd33e4..0e379843 100644 --- a/frontend/app/api/payments/wallets/route.ts +++ b/frontend/app/api/payments/wallets/route.ts @@ -55,10 +55,11 @@ export async function DELETE(req: NextRequest) { } try { const auth = await buildBackendRequestHeaders(req); + const proxiedHeaders = new Headers(auth.headers); const res = await fetch(`${API_BASE}/api/payments/wallets`, { method: "DELETE", headers: { - ...auth.headers, + ...proxiedHeaders, "Content-Type": "application/json", }, body: JSON.stringify(payload), @@ -67,7 +68,21 @@ export async function DELETE(req: NextRequest) { const raw = await res.text(); if (!res.ok) { const response = NextResponse.json( - { error: `Backend returned ${res.status}`, detail: raw.slice(0, 350) }, + { + error: `Backend returned ${res.status}`, + detail: raw.slice(0, 350), + proxy_debug: { + incoming_has_authorization: Boolean( + String(req.headers.get("authorization") || "").trim(), + ), + has_authorization: proxiedHeaders.has("authorization"), + has_entitlement: proxiedHeaders.has("x-polyweather-entitlement"), + has_forwarded_user_id: proxiedHeaders.has( + "x-polyweather-auth-user-id", + ), + has_forwarded_email: proxiedHeaders.has("x-polyweather-auth-email"), + }, + }, { status: res.status }, ); return applyAuthResponseCookies(response, auth.response);