's'
This commit is contained in:
@@ -3,6 +3,15 @@ import { getAdminToken } from "@/app/lib/pocketbase/admin";
|
||||
import { getPocketBaseConfig } from "@/config/services.config";
|
||||
import { getSalonApi } from "@/app/lib/salonApi";
|
||||
|
||||
/** 用户状态必须实时从数据库获取,禁止缓存 */
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const NO_CACHE_HEADERS = {
|
||||
"Cache-Control": "no-store, no-cache, must-revalidate, proxy-revalidate",
|
||||
Pragma: "no-cache",
|
||||
Expires: "0",
|
||||
};
|
||||
|
||||
const empty = {
|
||||
hasRecord: false,
|
||||
record: null,
|
||||
@@ -65,7 +74,7 @@ async function getPocketBaseJoinByWechat(wechatId: string) {
|
||||
export async function GET(request: NextRequest) {
|
||||
const wechatId = request.nextUrl.searchParams.get("wechat_id")?.trim();
|
||||
if (!wechatId) {
|
||||
return NextResponse.json(empty);
|
||||
return NextResponse.json(empty, { headers: NO_CACHE_HEADERS });
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -75,7 +84,7 @@ export async function GET(request: NextRequest) {
|
||||
{ timeoutMs: 6000 }
|
||||
);
|
||||
if (status === 200 && data && typeof data === "object") {
|
||||
return NextResponse.json(data);
|
||||
return NextResponse.json(data, { headers: NO_CACHE_HEADERS });
|
||||
}
|
||||
} catch {
|
||||
/* salonapi 不可用,回退直连 PocketBase */
|
||||
@@ -83,8 +92,8 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
const pbData = await getPocketBaseJoinByWechat(wechatId);
|
||||
if (pbData) {
|
||||
return NextResponse.json(pbData);
|
||||
return NextResponse.json(pbData, { headers: NO_CACHE_HEADERS });
|
||||
}
|
||||
|
||||
return NextResponse.json(empty);
|
||||
return NextResponse.json(empty, { headers: NO_CACHE_HEADERS });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user