修复 OAuth 回调域名:优先使用 NEXT_PUBLIC_SITE_URL 并添加根路径 code 兜底

This commit is contained in:
2569718930@qq.com
2026-05-24 17:55:32 +08:00
parent 5aa2a9e384
commit 2415167132
3 changed files with 32 additions and 3 deletions
+22 -1
View File
@@ -1,4 +1,5 @@
import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { DashboardEntry } from "@/components/dashboard/DashboardEntry";
export const metadata: Metadata = {
@@ -7,6 +8,26 @@ export const metadata: Metadata = {
"PolyWeather dashboard with METAR, MGM, DEB fusion forecast, multi-model comparison, and AI weather decision cards.",
};
export default function HomePage() {
export default async function HomePage({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const params = await searchParams;
const code = params.code;
if (typeof code === "string" && code.trim()) {
const usp = new URLSearchParams();
for (const [key, value] of Object.entries(params)) {
if (value != null) {
if (Array.isArray(value)) {
for (const v of value) usp.append(key, v);
} else {
usp.set(key, value);
}
}
}
const qs = usp.toString();
redirect(`/auth/callback${qs ? `?${qs}` : ""}`);
}
return <DashboardEntry />;
}