From e6c99c946a3b69c79ed33319daa566bec8291751 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Sun, 14 Jun 2026 04:40:02 +0800 Subject: [PATCH] Fix optional feedback auth fallback --- deploy.ps1 | 2 +- frontend/app/api/feedback/route.ts | 21 ++++++++++++++++--- .../__tests__/feedbackWorkflow.test.ts | 6 ++++++ scripts/validate_frontend_cache.sh | 2 +- tests/test_deployment_runtime_config.py | 12 +++++++++++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/deploy.ps1 b/deploy.ps1 index 04d6e2d3..de529e98 100644 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -1,4 +1,4 @@ -$VPS = "root@38.54.27.70" +$VPS = "root@172.245.214.111" $PROJECT = "/root/PolyWeather" Write-Host "🚀 Deploying to $VPS..." -ForegroundColor Cyan diff --git a/frontend/app/api/feedback/route.ts b/frontend/app/api/feedback/route.ts index bcdbd330..d3ff02f4 100644 --- a/frontend/app/api/feedback/route.ts +++ b/frontend/app/api/feedback/route.ts @@ -2,7 +2,6 @@ import { NextRequest, NextResponse } from "next/server"; import { applyAuthResponseCookies, buildBackendRequestHeaders, - requireBackendPaymentAuth, } from "@/lib/backend-auth"; import { buildProxyExceptionResponse, @@ -11,6 +10,21 @@ import { const API_BASE = process.env.POLYWEATHER_API_BASE_URL; +function emptyFeedbackResponse() { + return NextResponse.json( + { + feedback: [], + total: 0, + status_counts: {}, + }, + { + headers: { + "Cache-Control": "no-store", + }, + }, + ); +} + export async function GET(req: NextRequest) { if (!API_BASE) { return NextResponse.json( @@ -22,8 +36,9 @@ export async function GET(req: NextRequest) { let auth: Awaited> | null = null; try { auth = await buildBackendRequestHeaders(req); - const authError = requireBackendPaymentAuth(auth); - if (authError) return authError; + if (!auth.authUserId) { + return applyAuthResponseCookies(emptyFeedbackResponse(), auth.response); + } const upstream = new URL(`${API_BASE}/api/feedback`); const limit = req.nextUrl.searchParams.get("limit"); diff --git a/frontend/components/dashboard/scan-terminal/__tests__/feedbackWorkflow.test.ts b/frontend/components/dashboard/scan-terminal/__tests__/feedbackWorkflow.test.ts index ff11d06c..d2041840 100644 --- a/frontend/components/dashboard/scan-terminal/__tests__/feedbackWorkflow.test.ts +++ b/frontend/components/dashboard/scan-terminal/__tests__/feedbackWorkflow.test.ts @@ -69,6 +69,12 @@ export function runTests() { feedbackRouteSource.includes("limit"), "feedback API proxy must expose a GET endpoint for the current user's feedback status list", ); + assert( + feedbackRouteSource.includes("emptyFeedbackResponse") && + feedbackRouteSource.includes("if (!auth.authUserId)") && + !feedbackRouteSource.includes("const authError = requireBackendPaymentAuth(auth);"), + "feedback GET proxy must return an empty optional list instead of surfacing a 401 when no Supabase user identity is verified", + ); assert( dashboardSource.includes("