From 66e6b4c55703ba8be98031e411f4ffba84d5a258 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Sat, 16 Sep 2023 18:57:25 +0000 Subject: [PATCH] Remove max-age option from cookieOptions (#639) --- .changeset/dirty-books-begin.md | 5 +++++ packages/ssr/src/createBrowserClient.ts | 14 ++++++++------ packages/ssr/src/createServerClient.ts | 8 ++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 .changeset/dirty-books-begin.md 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 }) } } };