diff --git a/.changeset/dirty-books-begin.md b/.changeset/dirty-books-begin.md new file mode 100644 index 00000000..c067cbf7 --- /dev/null +++ b/.changeset/dirty-books-begin.md @@ -0,0 +1,5 @@ +--- +'@supabase/ssr': patch +--- + +Remove max-age option from cookieOptions diff --git a/packages/ssr/src/createBrowserClient.ts b/packages/ssr/src/createBrowserClient.ts index 47b85cf3..415a3ec6 100644 --- a/packages/ssr/src/createBrowserClient.ts +++ b/packages/ssr/src/createBrowserClient.ts @@ -70,14 +70,16 @@ export function createBrowserClient< if (typeof cookies.set === 'function') { return await cookies.set(key, value, { ...DEFAULT_COOKIE_OPTIONS, - ...cookieOptions + ...cookieOptions, + maxAge: DEFAULT_COOKIE_OPTIONS.maxAge }); } if (isBrowser()) { document.cookie = serialize(key, value, { ...DEFAULT_COOKIE_OPTIONS, - ...cookieOptions + ...cookieOptions, + maxAge: DEFAULT_COOKIE_OPTIONS.maxAge }); } }, @@ -85,16 +87,16 @@ export function createBrowserClient< if (typeof cookies.remove === 'function') { return await cookies.remove(key, { ...DEFAULT_COOKIE_OPTIONS, - maxAge: 0, - ...cookieOptions + ...cookieOptions, + maxAge: 0 }); } if (isBrowser()) { document.cookie = serialize(key, '', { ...DEFAULT_COOKIE_OPTIONS, - maxAge: 0, - ...cookieOptions + ...cookieOptions, + maxAge: 0 }); } } diff --git a/packages/ssr/src/createServerClient.ts b/packages/ssr/src/createServerClient.ts index 76827007..65c9c64b 100644 --- a/packages/ssr/src/createServerClient.ts +++ b/packages/ssr/src/createServerClient.ts @@ -53,9 +53,13 @@ export function createServerClient< storage: { getItem: async (key: string) => (await cookies.get(key)) ?? null, setItem: async (key: string, value: string) => - await cookies.set(key, value, { ...DEFAULT_COOKIE_OPTIONS, ...cookieOptions }), + await cookies.set(key, value, { + ...DEFAULT_COOKIE_OPTIONS, + ...cookieOptions, + maxAge: DEFAULT_COOKIE_OPTIONS.maxAge + }), removeItem: async (key: string) => - await cookies.remove(key, { ...DEFAULT_COOKIE_OPTIONS, maxAge: 0, ...cookieOptions }) + await cookies.remove(key, { ...DEFAULT_COOKIE_OPTIONS, ...cookieOptions, maxAge: 0 }) } } };