Bug report
Describe the bug
When running Realtime using the latest supabase CLI (1.123.4), using a web-address of localhost is causing an HTTP 431 Request header fields too large error. However, if I change nothing else but change the browser's url from localhost to 127.0.0.1 then everything works fine.
I am now seeing this issue on 127.0.0.1 as well.
Update 1
From an incognito browser (no cookies whatsoever) here is the request that is failing:
GET /realtime/v1/websocket?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0&vsn=1.0.0 HTTP/1.1
Host: 127.0.0.1:54321
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Sec-WebSocket-Version: 13
Origin: http://127.0.0.1:3000
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: Go4trD/Gc2EevJRrcr9Zwg==
DNT: 1
Sec-GPC: 1
Connection: keep-alive, Upgrade
Cookie: sb-127-auth-token.0=%7B%22access_token%22%3A%22eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNzAyNzg0Mzk2LCJpYXQiOjE3MDI3ODA3OTYsImlzcyI6Imh0dHA6Ly8xMjcuMC4wLjE6NTQzMjEvYXV0aC92MSIsInN1YiI6IjFhOGZkZDcyLWNlN2EtNDk0Ny04YmNkLTdmYzY5NDRhMTBjYSIsImVtYWlsIjoibmJhcnJvd0BpbnNwaXJldG1zdGVjaC5jb20iLCJwaG9uZSI6IiIsImFwcF9tZXRhZGF0YSI6eyJwcm92aWRlciI6ImtleWNsb2FrIiwicHJvdmlkZXJzIjpbImtleWNsb2FrIl19LCJ1c2VyX21ldGFkYXRhIjp7ImVtYWlsIjoibmJhcnJvd0BpbnNwaXJldG1zdGVjaC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiZnVsbF9uYW1lIjoiTmljaG9sYXMgQmFycm93IiwiaXNzIjoiaHR0cHM6Ly9vbmUtaWQuaW5zcGlyZXRtc2Nvbm5lY3QuY29tL3JlYWxtcy9pbnNwaXJlIiwibmFtZSI6Ik5pY2hvbGFzIEJhcnJvdyIsInBob25lX3ZlcmlmaWVkIjpmYWxzZSwicHJvdmlkZXJfaWQiOiI5M2I3ZmJiYi02Y2I4LTQ1MmMtYWJlNC01NTcwYjUxNjM4ZGUiLCJzdWIiOiI5M2I3ZmJiYi02Y2I4LTQ1MmMtYWJlNC01NTcwYjUxNjM4ZGUifSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJvYXV0aCIsInRpbWVzdGFtcCI6MTcwMjc4MDc5Nn1dLCJzZXNzaW9uX2lkIjoiNjBiNGM1ZDEtYTQyMi00NTIxLTg2ZTEtODlmZDE1OWZkOWJlIn0.nSE5ev-JZnbb2RLZyLRKVAUik5Gs_B8eEaJVXhO_p3Y%22%2C%22token_type%22%3A%22bearer%22%2C%22expires_in%22%3A3600%2C%22expires_at%22%3A1702784396%2C%22refresh_token%22%3A%22XdVS-LJkbPnbjBgA4DbIxQ%22%2C%22user%22%3A%7B%22id%22%3A%221a8fdd72-ce7a-4947-8bcd-7fc6944a10ca%22%2C%22aud%22%3A%22authenticated%22%2C%22role%22%3A%22authenticated%22%2C%22email%22%3A%22nbarrow%40inspiretmstech.com%22%2C%22email_confirmed_at%22%3A%222023-11-21T18%3A24%3A00.389495Z%22%2C%22phone%22%3A%22%22%2C%22confirmed_at%22%3A%222023-11-21T18%3A24%3A00.389495Z%22%2C%22last_sign_in_at%22%3A%222023-12-17T02%3A39%3A56.631000962Z%22%2C%22app_metadata%22%3A%7B%22provider%22%3A%22keycloak%22%2C%22providers%22%3A%5B%22keycloak%22%5D%7D%2C%22user_metadata%22%3A%7B%22email%22%3A%22nbarrow%40inspiretmstech.com%22%2C%22email_verified%22%3Atrue%2C%22full_name%22%3A%22Nicholas%20Barrow%22%2C%22iss%22%3A%22https%3A%2F%2Fone-id.inspiretmsconnect.com%2Frealms%2Finspire%22%2C%22name%22%3A%22Nicholas%20Barrow%22%2C%22phone_verified%22%3Afalse%2C%22provider_id%22%3A%2293b7fbbb-6cb8-452c-abe4-5570b51638de%22%2C%22sub%22%3A%2293b7fbbb-6cb8-452c-abe4-5570b51638de%22%7D%2C%22identities%22%3A%5B%7B%22identity_id%22%3A%2286357ebb-499f-45da-8591-69388747683d%22%2C%22id%22%3A%2293b7fbbb-6cb8-452c-abe4-5570b51638de%22%2C%22user_id%22%3A%221a8fdd72-ce7a-4947-8bcd-7fc6944a10ca%22%2C%22identity_data%22%3A%7B%22email%22%3A%22nbarrow%40inspiretmstech.com%22%2C%22email_verified%22%3Atrue%2C%22full_name%22%3A%22Nicholas%20Barrow%22%2C%22iss%22%3A%22https%3A%2F%2Fone-id.inspiretmsconnect.com%2Frealms%2Finspire%22%2C%22name%22%3A%22Nicholas%20Barrow%22%2C%22phone_verified%22%3Afalse%2C%22provider_id%22%3A%2293b7fbbb-6cb8-452c-abe4-5570b51638de%22%2C%22sub%22%3A%2293b7fbbb-6cb8-452c-abe4-5570b51638de%22%7D%2C%22provider%22%3A%22keycloak%22%2C%22last_sign_in_at%22%3A%222023-11-21T18%3A24%3A00.386993Z%22%2C%22created_at%22%3A%222023-11-21T18%3A24%3A00.387015Z%22%2C%22updated_at%22%3A%222023-12-17T02%3A39%3A55.902206Z%22%2C%22email%22%3A%22nbarrow%40inspiretmstech.com%22%7D%5D%2C%22created_at%22%3A%222023-11-21T18%3A24%3A00.383339Z%22%2C%22updated_at%22%3A%222023-12-17T02%3A39%3A56.641683Z%22%7D%2C%22provider_token%22%3A%22eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJXZTlwZ0pJMD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Yqjx-ILSiCg3I460pzhlAQsK3VVsRjjK1NKaDLU%22%7D
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: websocket
Sec-Fetch-Site: same-site
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Here is the response:
HTTP/1.1 431 Request Header Fields Too Large
Content-Length: 0
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Upstream-Latency: 1
X-Kong-Proxy-Latency: 1
Via: kong/2.8.1
Update 2
This looks related to the NGINX instance that runs Kong. Kong has an nginx_http_client_header_buffer_size variable (https://legacy-gateway--kongdocs.netlify.app/enterprise/2.4.x/property-reference/?_ga=2.40455847.426939276.1702781538-1754633255.1702781538#nginx_http_client_header_buffer_size). From the NGINX docs, (http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_buffer_size), the default value os 1k. However, my request above (per Firefox) is aroung 6k.
Update 3
Based on this it looks like KONG_NGINX_HTTP_CLIENT_HEADER_BUFFER_SIZE needs to be increased for SSR and cookies, as the cookies are much larger than the default 1k request size for Realtime.
To Reproduce
- Try connecting to realtime from a Next.js (14) website from
127.0.0.1, and everything works fine
- Change absolutely nothing else, other than switching the
127.0.0.1 in the URL to localhost and the websockets fail
NOTE: Chrome does not report websocket errors well; I had to use Firefox to see that this was a 431 error
Expected behavior
There should be no functional difference between localhost and 127.0.0.1
Screenshots
System information
- OS:
macOS 13.3 (22E252)
- Version of supabase-js:
^2.38.4
- Version of Node.js:
v18.17.1
Bug report
Describe the bug
When running Realtime using the latest supabase CLI (1.123.4), using a web-address oflocalhostis causing an HTTP 431Request header fields too largeerror. However, if I change nothing else but change the browser's url fromlocalhostto127.0.0.1then everything works fine.I am now seeing this issue on
127.0.0.1as well.Update 1
From an incognito browser (no cookies whatsoever) here is the request that is failing:
Here is the response:
Update 2
This looks related to the NGINX instance that runs Kong. Kong has an
nginx_http_client_header_buffer_sizevariable (https://legacy-gateway--kongdocs.netlify.app/enterprise/2.4.x/property-reference/?_ga=2.40455847.426939276.1702781538-1754633255.1702781538#nginx_http_client_header_buffer_size). From the NGINX docs, (http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_buffer_size), the default value os 1k. However, my request above (per Firefox) is aroung 6k.Update 3
Based on this it looks like
KONG_NGINX_HTTP_CLIENT_HEADER_BUFFER_SIZEneeds to be increased for SSR and cookies, as the cookies are much larger than the default1krequest size for Realtime.To Reproduce
127.0.0.1, and everything works fine127.0.0.1in the URL tolocalhostand the websockets failExpected behavior
There should be no functional difference between localhost and
127.0.0.1Screenshots
System information
macOS 13.3 (22E252)^2.38.4v18.17.1