Cookie issue leads to 502 Gateway Error with supabase SSR
philmas 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
I am not sure whether this is related to this discussion. However, I seem to be running into an issue where I obtain a 502 Bad Gateway
error in my application to do with cookies setup. The supabase instance reports success.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Create an SSR authentication flow as described in the docs
- Obtain a valid cookie by logging in.
- Wait until cookie refresh needs to occur and visit the website.
- See error
Expected behavior
Should function normally. If I remove my cookies, the site functions normally and login works flawlessly. Only when cookie refresh needs to occur it leads to an 502. Cookie size is about 2300.
Log Details
No errors are to be found anywhere except for a successful auth log from supabase. Other sveltekit applications have the same issue. Making it likely that it is a supabase issue / incorrect implementation of code.
{
"component": "api",
"level": "info",
"method": "POST",
"msg": "request started",
"path": "/token",
"referer": "<url>",
"remote_addr": "172.19.0.1",
"time": "2024-06-09T20:41:07Z",
"timestamp": "2024-06-09T20:41:07Z"
}
{
"action": "login",
"instance_id": "00000000-0000-0000-0000-000000000000",
"level": "info",
"login_method": "token",
"metering": true,
"msg": "Login",
"time": "2024-06-09T20:41:07Z",
"user_id": "<user-id>"
}
{
"auth_event": {
"action": "token_refreshed",
"actor_id": "<actor_id>",
"actor_username": "<username>",
"actor_via_sso": false,
"log_type": "token"
},
"component": "api",
"duration": 13129690,
"level": "info",
"method": "POST",
"msg": "request completed",
"path": "/token",
"referer": "<url>",
"remote_addr": "172.19.0.1",
"status": 200,
"time": "2024-06-09T20:41:07Z",
"timestamp": "2024-06-09T20:41:07Z"
}
System information
- OS: Linux
- Browser Chrome
- Version of supabase-js: 2.43.4
- Version of Node.js: 20
Issue was related to the header size.
Solved by adding the following to the proxy configuration.
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
large_client_header_buffers 4 16k;