I have a NextJS app using middleware for login (Google and Facebook for now) and it works great locally. When I deploy on Vercel I can never get the social logins to trigger. When someone clicks on the login button it just refreshes the current page. I added a bunch of logging information and it could be related to cookies? My auth options look like this:
cookies: {
sessionToken: {
name: process.env.NODE_ENV === 'production'
? '__Host-next-auth.csrf-token'
: 'next-auth.session-token', // Local use
options: {
httpOnly: true,
sameSite: "lax",
path: "/",
secure: process.env.NODE_ENV === "production",
},
},
},
pages: {
signIn: '/auth/signin',
},
I used to only have next-auth.session-token as the cookie to check, either way doesn’t work though. See anything I’m doing wrong? This has been a problem for over a week and I can’t find any answers googling. Hard to test when locally it’s fine. I added my full domain name to the google auth redirecturl. But it fails the same on both facebook and google. Previously I didn’t set the signin custom page. So that also is unrelated to the issue. I see 3 cookies being set in the Network Storage > Cookies tab: __Host-next-auth.csrf-token, __Secure-next-auth.callback-url, and next-auth.session-token.