fix: cookies cannot be used by browser extension

when cookies are set with same site policy, they cannot be used in an iframe (as the official extension does)
This commit is contained in:
Sonny
2023-11-20 13:48:08 +01:00
parent b5d70d75d3
commit 98f1dc4e31

View File

@@ -19,6 +19,12 @@ const checkProvider = (provider: string) => provider === "google";
const checkAccountDataReceived = (profile: Profile) =>
!!profile?.sub && !!profile?.email;
const cookieOptions = {
sameSite: "None",
path: "/",
secure: true,
};
export const authOptions = {
providers: [
GoogleProvider({
@@ -75,5 +81,19 @@ export const authOptions = {
error: PATHS.LOGIN,
signOut: PATHS.LOGOUT,
},
cookies: {
sessionToken: {
name: "next-auth.session-token",
options: cookieOptions,
},
callbackUrl: {
name: "next-auth.callback-url",
options: cookieOptions,
},
csrfToken: {
name: "next-auth.csrf-token",
options: cookieOptions,
},
},
} as NextAuthOptions;
export default NextAuth(authOptions);