Reverse Proxy
Errors with Reverse proxies and Supabase authentication
Experiencing authentication errors after some time?
If you notice that users are being logged out or receiving authentication errors after a period of time, this is likely related to how Supabase refreshes the access_token. Supabase periodically attempts to refresh authentication tokens, which requires sending and receiving larger HTTP headers. If your reverse proxy is not configured to handle these larger headers, the token refresh process may fail, resulting in errors for your users.
To resolve this, you need to adjust your reverse proxy settings to allow for larger header sizes and longer timeouts. Below are recommended settings for Nginx:
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_connect_timeout 60s;
proxy_read_timeout 60s;
proxy_send_timeout 60s;