Skip to content

Commit

Permalink
Remove max-age option from cookieOptions (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
silentworks authored Sep 16, 2023
1 parent c48bb87 commit 66e6b4c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-books-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@supabase/ssr': patch
---

Remove max-age option from cookieOptions
14 changes: 8 additions & 6 deletions packages/ssr/src/createBrowserClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,33 @@ 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
});
}
},
removeItem: async (key: string) => {
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
});
}
}
Expand Down
8 changes: 6 additions & 2 deletions packages/ssr/src/createServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
}
};
Expand Down

0 comments on commit 66e6b4c

Please sign in to comment.