Open coyotte508 opened 8 months ago
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 OriginHeaderTooBigError
: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html
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 hooks.server.js
with a handle
hook that does:
/** @type {import('@sveltejs/kit').Handle} */
export async function handle({ event, resolve }) {
const response = await resolve(event);
response.headers.delete('Link');
return response;
}
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.
I do think it's reasonable to consider the state of the internet infrastructure when making design decisions though and at least document it as a concern.
IIS and Apache also have default limitations you should keep in mind.
@http-teapot note that another fix is in your app code, you can create a
hooks.server.js
with ahandle
hook that does:/** @type {import('@sveltejs/kit').Handle} */ export async function handle({ event, resolve }) { const response = await resolve(event); response.headers.delete('Link'); return response; }
Any idea what the implications of this are?
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