Skip to content

Instantly share code, notes, and snippets.

@FrancisGregori
Created November 26, 2023 02:11
Show Gist options
  • Save FrancisGregori/e4d363124f2401bd65e3b0b5f496980c to your computer and use it in GitHub Desktop.
Save FrancisGregori/e4d363124f2401bd65e3b0b5f496980c to your computer and use it in GitHub Desktop.
import NextAuth from 'next-auth/next';
import GoogleProvider from 'next-auth/providers/google';
const useSecureCookies = !!process.env.VERCEL_URL;
const handler = NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID ?? '',
clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? '',
}),
],
secret: process.env.NEXTAUTH_SECRET,
cookies: {
sessionToken: {
name: `${useSecureCookies ? '__Secure-' : ''}next-auth.session-token`,
options: {
httpOnly: true,
sameSite: 'lax',
path: '/',
domain: `.${process.env.BASE_DOMAIN}`,
secure: useSecureCookies,
},
},
},
});
export { handler as GET, handler as POST };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment