Skip to content
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

[Feature] Allow very large headers with MRT #2160

Open
johnboxall opened this issue Dec 4, 2024 · 0 comments
Open

[Feature] Allow very large headers with MRT #2160

johnboxall opened this issue Dec 4, 2024 · 0 comments

Comments

@johnboxall
Copy link
Collaborator

johnboxall commented Dec 4, 2024

Making a HTTP request with large headers to a Managed Runtime environment results in a HTTP 413 response:

$ curl 'https://pwa-kit.mobify-storefront.com/' \
    -H 'x-mobify-cachebreaker: 1' \
    -H "x-huge-header: $(python3 -c 'print("x" * 10240)')"
HTTP header is larger than 10240 bytes.

This MRT environment constraint is documented:

The maximum size of the HTTP request line and headers is 10240 bytes. Requests exceeding this size return an HTTP 413 Content Too Large.

In web browsers, most large headers come from cookies.

If a MRT Environment has enabled cookies AND many large cookies are set by the site, it is possible to hit this constraint.

Most PWA Kit sites should not enable the MRT allow_cookies setting. It is only required if you are altering server side rendering based on cookies.

As a workaround, the MRT's Request Processor can be used to either remove or alter the cookie header to prevent hitting this limit:

// request-processor.js
export const processRequest = function removeCookies({
    headers,
    path,
    querystring,
}) {
    headers.deleteHeader('cookie')
    return {path, querystring}
}

Ideally, this constraint wouldn't exist or at least, it would be possible to customize the error message to help shoppers continue their sessions.

@johnboxall johnboxall changed the title [BUG] Requests with large headers return HTTP 413 [Feature] Allow very large headers with MRT Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant