From 39c96dce5978ec7728a8e1f5c41cad0c5a56d14d Mon Sep 17 00:00:00 2001 From: sijinhui Date: Fri, 9 Aug 2024 18:18:34 +0800 Subject: [PATCH] debug domain --- lib/auth.ts | 30 +++++++++++++++--------------- middleware.ts | 1 + 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/auth.ts b/lib/auth.ts index abdd038e5..39dd5be54 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -131,21 +131,21 @@ export const authOptions: NextAuthOptions = { }, adapter: PrismaAdapter(prisma), session: { strategy: "jwt", maxAge: 3 * 24 * 60 * 60 }, - cookies: { - sessionToken: { - name: `${SECURE_COOKIES ? "__Secure-" : ""}next-auth.session-token`, - options: { - httpOnly: true, - sameSite: "lax", - path: "/", - // When working on localhost, the cookie domain must be omitted entirely (https://stackoverflow.com/a/1188145) - // domain: VERCEL_DEPLOYMENT - // ? `.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}` - // : undefined, - secure: SECURE_COOKIES, - }, - }, - }, + // cookies: { + // sessionToken: { + // name: `${SECURE_COOKIES ? "__Secure-" : ""}next-auth.session-token`, + // options: { + // httpOnly: true, + // sameSite: "lax", + // path: "/", + // // When working on localhost, the cookie domain must be omitted entirely (https://stackoverflow.com/a/1188145) + // // domain: VERCEL_DEPLOYMENT + // // ? `.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}` + // // : undefined, + // secure: SECURE_COOKIES, + // }, + // }, + // }, callbacks: { jwt: async ({ token, user }) => { // const current_time = Math.floor(Date.now() / 1000); diff --git a/middleware.ts b/middleware.ts index 1a8c7ff79..8b9e3b83d 100644 --- a/middleware.ts +++ b/middleware.ts @@ -11,6 +11,7 @@ export default async function middleware(req: NextRequest) { const path = `${url.pathname}${ searchParams.length > 0 ? `?${searchParams}` : "" }`; + console.log('----', url) // 直接将/app/下面路由重定向到顶层 if (path.startsWith('/app')) { return NextResponse.redirect(new URL(path.replace('/app', ''), req.url), 301);