问题
We have a requirement to send large data as part of URL which will be read by angular to render the page. Url is of more than 10000 characters. But cloudfront is returning below error -
Bad request. Generated by cloudfront (CloudFront) Request ID: I2fOApzZr4psKrWsY6abezp5R0m30zKDKE7c0MuB_JkjWbvxz5GVnQ==
Browser console returns error code 413 with below message -
Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
Is there any settings in cloud front which can allow to accept large URL request.
I know on apache that there are settings like LimitRequestBody which can allow large inputs, but request is not reaching to apache and error out by cloudfront itself.
When I played with the number of characters - cloudfront breaks after 8226 characters.
回答1:
This isn't supported. CloudFront has these hard limits, which are reasonable for most applications:
Maximum length of a request, including headers and query strings: 20,480 bytes
Maximum length of a URL: 8,192 bytes
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
The apparent discrepancy between 8,226 − 8,192 = 34 is probably attributable to the length of your hostname and http://
if you're counting that. CloudFront's documentation says "URL" but the limit may actually only apply to the combined length of path + query-string, since the Host:
header is separate from the rest of the request, in the actual HTTP protocol.
The limits mentioned above, and some others, do not appear to be negotiable.
Other limits, such as bandwidth (40 Gbps), number of web distributions per AWS account (200) are merely default limits, which you can potentially have increased by submitting a request to AWS support describing your use case, but that does not appear to be the case, here.
Angular can't call api directly because of some authentication issues.
This sort of sounds like a case for ajax calls to a proxy REST API that fetches the data from the source requiring authorization, so the browser side code doesn't have to... maybe something in Lambda behind API Gateway.
来源:https://stackoverflow.com/questions/40244883/cloudfront-responds-with-a-status-of-413-request-entity-too-large