-
Notifications
You must be signed in to change notification settings - Fork 550
vary should be set to 'Accept' in the response header #59
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
Conversation
I'm trying to get Is there an update on this issue or a reason it isn't merged in? @omrisiri @gsingh04 |
@omrisiri Were you able to get this working ( I merged tested this PR, and confirmed it does work when you access the API directly (when setting Example: Request png w/
Request png w/
|
In order for this to work with cloudfront you will need to whitelist the Accept header in the behaviors tab in the distribution settings |
@omrisiri I actually just ended up uncommenting these lines: https://github.com/awslabs/serverless-image-handler/blob/50856dc17ea7671829f3f940ae27f3a35807b59f/deployment/serverless-image-handler.template#L475-L479 See #32 |
if thumbor_response.status_code != 200: | ||
return response_formater(status_code=thumbor_response.status_code) | ||
if vary: | ||
vary = thumbor_response.headers['vary'] | ||
vary = 'Accept' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omrisiri We don't need to change anything here. If we forward the headers from cloudfront (https://aws.amazon.com/premiumsupport/knowledge-center/configure-cloudfront-to-forward-headers/ choose accept instead of host), this will work as it is. And I think we will have to forward the headers anyway since the thumbor needs to know the header value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jainraj @omrisiri I've configured cloudfront to forward the Accept
header, which works, but throws an error when you pass a format filter, eg: https://dlywxk1dfco56.cloudfront.net/Uz-eU0TnL0X_2ZbKHeCc1-lVyfs=/716x716/filters:focal(839x839:841x841):format(jpeg):quality(61):sharpen(0.5,0.5,true)/development.craftcms.stealthmonitoring/headshots/Rob-Cherun.jpg
Request the moderators to close the PR and add in documentation that we will need to forward ACCEPT header in CloudFront for AUTO_WEBP to work as expected |
I can verify @jainraj's solution works. Shouldn't we add the Accepts whitelist header to the cloudfront dist as part of the default configuration? |
Just came across an issue using @jainraj's solution (adding the Accept header to whitelist). It throws an error when you try to set the format via the
|
Resolved with v4.0.0 |
When enabling webp we need to return vary: 'Accept' header rather than take it from the request headers since it doesn't exist there and will throw an exception
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.