[GH-ISSUE #8784] nextCookies plugin leaks internal cookie __better-auth-cookie-store to clients #28514

Open
opened 2026-04-17 19:58:06 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @smndtrl on GitHub (Mar 26, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8784

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Use nextConfig() plugin
  2. Call any API

Current vs. Expected behavior

Internal cookie __better-auth-cookie-store is never sent to the client.

A empty cookie __better-auth-cookie-store is sent to the client because the delete on the cookieStore only sets the cookies value to empty and doesn't remove the key from the internal map.

https://github.com/better-auth/better-auth/blob/4be065c50543afd89f67427249b0cb07fdd2ad1f/packages/better-auth/src/integrations/next-js.ts#L41-L54

What version of Better Auth are you using?

main

System info

...

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

IMHO detecting Server Components vs Server Actions/Router Handlers should not have a side effect

Originally created by @smndtrl on GitHub (Mar 26, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8784 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Use nextConfig() plugin 2. Call any API ### Current vs. Expected behavior Internal cookie `__better-auth-cookie-store` is never sent to the client. A empty cookie `__better-auth-cookie-store` is sent to the client because the delete on the cookieStore only sets the cookies value to empty and doesn't remove the key from the internal map. https://github.com/better-auth/better-auth/blob/4be065c50543afd89f67427249b0cb07fdd2ad1f/packages/better-auth/src/integrations/next-js.ts#L41-L54 ### What version of Better Auth are you using? main ### System info ```bash ... ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context IMHO detecting Server Components vs Server Actions/Router Handlers should not have a side effect
GiteaMirror added the platformcorebug labels 2026-04-17 19:58:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28514