This commit is contained in:
parent
975fa1a7e2
commit
5ca0e9ad80
|
|
@ -19,28 +19,13 @@ export const metadata: Metadata = {
|
|||
title: "Login"
|
||||
}
|
||||
|
||||
interface LoginPageProps {
|
||||
searchParams: { message: string; email?: string };
|
||||
params: { locale: string };
|
||||
req: NextPageContext['req']; // 用 NextPageContext 的 req 类型来定义
|
||||
}
|
||||
|
||||
|
||||
// export default async function Login({
|
||||
// searchParams,
|
||||
// params: { locale },
|
||||
// req, // 请求对象
|
||||
// }: {
|
||||
// searchParams: { message: string; email?: string };
|
||||
// params: { locale: string };
|
||||
// req: Request; // 获取请求对象
|
||||
// }) {
|
||||
|
||||
export default async function Login({
|
||||
searchParams,
|
||||
params: { locale },
|
||||
req, // 请求对象
|
||||
}: LoginPageProps) {
|
||||
}: {
|
||||
searchParams: { message: string; email?: string };
|
||||
params: { locale: string };
|
||||
}) {
|
||||
const cookieStore = cookies()
|
||||
|
||||
const localeString = locale;
|
||||
|
|
@ -60,31 +45,31 @@ export default async function Login({
|
|||
.eq("is_home", true)
|
||||
.maybeSingle();
|
||||
|
||||
// Define the clearCookies function for server-side execution
|
||||
const clearCookies = async () => {
|
||||
// From request headers or environment variables
|
||||
let hosturl: string | undefined;
|
||||
// // Define the clearCookies function for server-side execution
|
||||
// const clearCookies = async () => {
|
||||
// // From request headers or environment variables
|
||||
// let hosturl: string | undefined;
|
||||
|
||||
// Option 1: Get host from request headers (useful for dynamic requests)
|
||||
const hostHeader = req.headers.get('host');
|
||||
if (hostHeader) {
|
||||
hosturl = `http://${hostHeader}`; // Construct full URL
|
||||
} else {
|
||||
// Option 2: Use environment variable as fallback
|
||||
hosturl = process.env.SUPABASE_URL; // Ensure you have this set up in your environment variables
|
||||
}
|
||||
// // Option 1: Get host from request headers (useful for dynamic requests)
|
||||
// const hostHeader = req.headers.get('host');
|
||||
// if (hostHeader) {
|
||||
// hosturl = `http://${hostHeader}`; // Construct full URL
|
||||
// } else {
|
||||
// // Option 2: Use environment variable as fallback
|
||||
// hosturl = process.env.SUPABASE_URL; // Ensure you have this set up in your environment variables
|
||||
// }
|
||||
|
||||
if (hosturl) {
|
||||
await fetch(`${hosturl}/api/clearcookies`, {
|
||||
method: "POST",
|
||||
});
|
||||
} else {
|
||||
console.error("Host URL is not available");
|
||||
}
|
||||
};
|
||||
// if (hosturl) {
|
||||
// await fetch(`${hosturl}/api/clearcookies`, {
|
||||
// method: "POST",
|
||||
// });
|
||||
// } else {
|
||||
// console.error("Host URL is not available");
|
||||
// }
|
||||
// };
|
||||
|
||||
if (!homeWorkspace) {
|
||||
await clearCookies(); // Clear cookies if home workspace is not found
|
||||
//await clearCookies(); // Clear cookies if home workspace is not found
|
||||
return redirect(`/${localeString}/login?message=sessionExpired`);
|
||||
}
|
||||
return redirect(`/${localeString}/${homeWorkspace.id}/chat`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue