debug domain

This commit is contained in:
sijinhui 2024-08-09 18:18:34 +08:00
parent b0a53d9f6c
commit 39c96dce59
2 changed files with 16 additions and 15 deletions

View File

@ -131,21 +131,21 @@ export const authOptions: NextAuthOptions = {
}, },
adapter: PrismaAdapter(prisma), adapter: PrismaAdapter(prisma),
session: { strategy: "jwt", maxAge: 3 * 24 * 60 * 60 }, session: { strategy: "jwt", maxAge: 3 * 24 * 60 * 60 },
cookies: { // cookies: {
sessionToken: { // sessionToken: {
name: `${SECURE_COOKIES ? "__Secure-" : ""}next-auth.session-token`, // name: `${SECURE_COOKIES ? "__Secure-" : ""}next-auth.session-token`,
options: { // options: {
httpOnly: true, // httpOnly: true,
sameSite: "lax", // sameSite: "lax",
path: "/", // path: "/",
// When working on localhost, the cookie domain must be omitted entirely (https://stackoverflow.com/a/1188145) // // When working on localhost, the cookie domain must be omitted entirely (https://stackoverflow.com/a/1188145)
// domain: VERCEL_DEPLOYMENT // // domain: VERCEL_DEPLOYMENT
// ? `.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}` // // ? `.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`
// : undefined, // // : undefined,
secure: SECURE_COOKIES, // secure: SECURE_COOKIES,
}, // },
}, // },
}, // },
callbacks: { callbacks: {
jwt: async ({ token, user }) => { jwt: async ({ token, user }) => {
// const current_time = Math.floor(Date.now() / 1000); // const current_time = Math.floor(Date.now() / 1000);

View File

@ -11,6 +11,7 @@ export default async function middleware(req: NextRequest) {
const path = `${url.pathname}${ const path = `${url.pathname}${
searchParams.length > 0 ? `?${searchParams}` : "" searchParams.length > 0 ? `?${searchParams}` : ""
}`; }`;
console.log('----', url)
// 直接将/app/下面路由重定向到顶层 // 直接将/app/下面路由重定向到顶层
if (path.startsWith('/app')) { if (path.startsWith('/app')) {
return NextResponse.redirect(new URL(path.replace('/app', ''), req.url), 301); return NextResponse.redirect(new URL(path.replace('/app', ''), req.url), 301);