Reduce Supabase disk IO

This commit is contained in:
2569718930@qq.com
2026-05-29 17:22:33 +08:00
parent 9e3a4e2f45
commit 2269aaefd7
63 changed files with 4637 additions and 410 deletions
+17 -3
View File
@@ -11,6 +11,7 @@ import {
getLocalDevAuthPayload,
isLocalFullAccessHost,
} from "@/lib/local-dev-access";
import { hasSupabaseServerEnv } from "@/lib/supabase/server";
const API_BASE = process.env.POLYWEATHER_API_BASE_URL;
@@ -33,8 +34,22 @@ export async function GET(req: NextRequest) {
);
}
let auth: Awaited<ReturnType<typeof buildBackendRequestHeaders>> | null = null;
try {
const auth = await buildBackendRequestHeaders(req);
auth = await buildBackendRequestHeaders(req);
if (
hasSupabaseServerEnv() &&
!auth.authUserId &&
!req.headers.get("authorization")
) {
const response = NextResponse.json({
authenticated: false,
subscription_active: false,
points: 0,
});
return applyAuthResponseCookies(response, auth.response);
}
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 6000);
let res: Response;
@@ -98,8 +113,7 @@ export async function GET(req: NextRequest) {
const response = NextResponse.json(data);
return applyAuthResponseCookies(response, auth.response);
} catch (error) {
const auth = await buildBackendRequestHeaders(req);
if (auth.authUserId) {
if (auth?.authUserId) {
const response = NextResponse.json({
authenticated: true,
user_id: auth.authUserId,