Forward Supabase identity for terminal data proxies

This commit is contained in:
2569718930@qq.com
2026-06-14 07:26:15 +08:00
parent b1edb1b7e1
commit abe08de769
3 changed files with 19 additions and 0 deletions
@@ -106,6 +106,7 @@ export async function GET(req: NextRequest) {
? NO_STORE_CACHE_CONTROL ? NO_STORE_CACHE_CONTROL
: cachePolicy.responseCacheControl, : cachePolicy.responseCacheControl,
fetchCache: "no-store", fetchCache: "no-store",
includeSupabaseIdentity: true,
publicMessage: "Failed to fetch city detail batch", publicMessage: "Failed to fetch city detail batch",
revalidateSeconds: cachePolicy.revalidateSeconds, revalidateSeconds: cachePolicy.revalidateSeconds,
signal: controller.signal, signal: controller.signal,
+1
View File
@@ -75,6 +75,7 @@ export async function GET(req: NextRequest) {
fetchCache: "no-store", fetchCache: "no-store",
publicMessage: "Failed to fetch scan terminal data", publicMessage: "Failed to fetch scan terminal data",
revalidateSeconds: cachePolicy.revalidateSeconds, revalidateSeconds: cachePolicy.revalidateSeconds,
includeSupabaseIdentity: true,
signal: controller.signal, signal: controller.signal,
timeoutPublicMessage: "Scan terminal request timed out", timeoutPublicMessage: "Scan terminal request timed out",
timing: timer, timing: timer,
@@ -50,4 +50,21 @@ export function runTests() {
helperSource.includes("authEmail: identity?.email || null"), helperSource.includes("authEmail: identity?.email || null"),
"backend auth helper must verify incoming Supabase bearer tokens and forward trusted user identity headers to backend services", "backend auth helper must verify incoming Supabase bearer tokens and forward trusted user identity headers to backend services",
); );
const scanTerminalRoute = fs.readFileSync(
path.join(projectRoot, "app", "api", "scan", "terminal", "route.ts"),
"utf8",
);
const cityDetailBatchRoute = fs.readFileSync(
path.join(projectRoot, "app", "api", "cities", "detail-batch", "route.ts"),
"utf8",
);
assert(
scanTerminalRoute.includes("includeSupabaseIdentity: true"),
"scan terminal proxy must forward the Supabase identity; otherwise paid users hit backend 401 even when /api/auth/me is active",
);
assert(
cityDetailBatchRoute.includes("includeSupabaseIdentity: true"),
"city detail batch proxy must forward the Supabase identity; otherwise paid users see empty charts with backend 401",
);
} }