-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
SvelteKit generates large Link header, causing a 502 with Nginx #11084
Comments
I don't know what we could reasonably do about this besides document it. I don't think SvelteKit should drop down its maximum size of this header because you might have nginx in front of it with the default configuration. We can't in general tell anything about limitations of the proxy sitting in front of the application. |
For the nginx noobs like me, to view the error logs you need to run: sudo tail -f /var/log/nginx/error.log If that doesn't work, maybe your error logs are located somewhere else: nginx -T | grep 'log'
# this comands highlights the 'log' word in your entire nginx config, so you can see where they are located |
SvelteKit cannot be placed behind Cloudfront once the header has reached Cloudfront's limit. See documentation here about Feels very critical to me as turning off Cloudfront puts a strain on our servers |
@http-teapot note that another fix is in your app code, you can create a /** @type {import('@sveltejs/kit').Handle} */
export async function handle({ event, resolve }) {
const response = await resolve(event);
response.headers.delete('Link');
return response;
} |
Describe the bug
When the app grows, the
Link
header becomes bigger and bigger.At a certain point, nginx will display 502s and error. This happens when the
Link
header nears 4kb.It's possible to work around this by tweaking nginx config, but this error is hard to diagnose and it shouldn't happen out of the blue with the most popular reverse proxy.
Reproduction
In the
handle
hook, you can add this to reproduce it happening:Then if sveltekit is running behind nginx with default config, it will send a 502.
Logs
System Info
Severity
serious, but I can work around it
Additional Information
This can be fixed on Nginx side with this:
Still, this error is hard to debug and it shouldn't happen with the most popular reverse proxy
The text was updated successfully, but these errors were encountered: