This commit is contained in:
eric
2026-03-11 23:10:18 -05:00
parent 26f1de5fb6
commit efe816915d
3 changed files with 9 additions and 6 deletions

View File

@@ -11,13 +11,15 @@ export async function GET(request: NextRequest) {
return NextResponse.json({ ok: false, error: "未配置 PAYMENT_API_URL" }, { status: 500 });
}
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 25000);
const res = await fetch(
`${config.apiUrl}/zpay_order_status?out_trade_no=${encodeURIComponent(orderId)}`,
{ cache: "no-store" }
);
{ cache: "no-store", signal: controller.signal }
).finally(() => clearTimeout(timeout));
const data = await res.json().catch(() => ({}));
return NextResponse.json({ ok: true, paid: !!data?.paid });
} catch (e) {
return NextResponse.json({ ok: false, paid: false, error: String(e) }, { status: 500 });
} catch {
return NextResponse.json({ ok: true, paid: false });
}
}

View File

@@ -25,5 +25,6 @@
"eslint-config-next": "16.1.6",
"tailwindcss": "^4",
"typescript": "^5"
}
},
"packageManager": "pnpm@10.25.0+sha1.2cfb3ab644446565c127f58165cc76368c9c920b"
}

View File

@@ -4,7 +4,7 @@ import type { NextRequest } from "next/server";
const LOCALES = ["zh", "en"];
const DEFAULT_LOCALE = "zh";
export function middleware(request: NextRequest) {
export function proxy(request: NextRequest) {
const { pathname } = request.nextUrl;
const hasLocale = LOCALES.some(