Failed to set cookie when OAuth username includes non-ASCII characters
SDuck4 opened this issue · comments
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
The OAuth authentication flow was processed in accordance with this guide, but some users were not authenticated.
I've looked into it and found that when set up cookies in Supabase, it doesn't filter the non-ASCII characters in OAuth user information, so the cookies don't set up properly.
I solved it by customizing cookie method as follows, but I think it's a fundamental problem that needs to be solved in this library.
set(name: string, value: string, options: CookieOptions) {
const nonAsciiRegex = /[^\x00-\x7F]/g;
const valueNonAscii = value.replaceAll(nonAsciiRegex, "");
cookieStore.set({ name, value: valueNonAscii, ...options });
},
These are the names that failed to create cookies while testing.
- Алиса
- カリーム
- 關聖
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Sign-in with OAuth that has non-ASCII username
Expected behavior
A clear and concise description of what you expected to happen.
- Non-ASCII usernames are also typically set to cookies.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- OS: macOS, Windows, iOS, Android
- Browser: chrome
- Version of supabase-js: 2.39.0 and ssr is 0.0.9
- Version of Node.js: 18.19.0
Additional context
Add any other context about the problem here.