Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[supabase/ssr] Auth token chunking broken #738

Open
2 tasks done
bombillazo opened this issue Feb 5, 2024 · 1 comment
Open
2 tasks done

[supabase/ssr] Auth token chunking broken #738

bombillazo opened this issue Feb 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bombillazo
Copy link

bombillazo commented Feb 5, 2024

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

In a Next.JS application, when the user JWT access token is too large, the supabase auth library splits it into sections and sends it in the cookies in the following manner:

sb-project-auth-token.0
sb-project-auth-token.1
...
sb-project-auth-token.n

These cookies are randomly deleted from the browser storage, which causes auth issues in the application. We have not identified the cause, but it happens when the JWT is split into multiple cookies.

To Reproduce

  1. Create a user in your auth table and add a large dummy raw_user_meta_data JSON object
  2. In a next page, add the SSR createBrowserClient
  3. Login
  4. Check the cookies panel in your browser and look for sb-project-auth-token.0
  5. Navigate around the page, refresh or wait a while
  6. Cookies are randomly deleted

Expected behavior

Cookies are kept in memory until a signout event happens or the cookies are cleared manually.

System information

  • Browser (if applies) Firefox
  • Version of supabase-js: 2.39.3

Additional context

We are using the Next.js framework

@bombillazo bombillazo added the bug Something isn't working label Feb 5, 2024
@bombillazo bombillazo changed the title [supabase/ssr] Auth token chunking broken in local [supabase/ssr] Auth token chunking broken Feb 14, 2024
@meyer9
Copy link

meyer9 commented May 12, 2024

We've found this happen when the server thinks the cookie is invalid. For us, this happened when our framework wasn't url decoding the cookie, so it failed to JSON.parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants