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

CloudFront needs to configured to keep "Set-Cookie" header #295

Open
wsxiaoys opened this issue May 12, 2022 · 2 comments
Open

CloudFront needs to configured to keep "Set-Cookie" header #295

wsxiaoys opened this issue May 12, 2022 · 2 comments

Comments

@wsxiaoys
Copy link

By default CloudFront removed "Set-Cookie" Header from response, when behavior is set to "Not forwarding cookie to origin".

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Cookies.html

Don’t forward cookies to your origin – CloudFront doesn’t cache your objects based on cookie sent by the viewer. In addition, CloudFront removes cookies before forwarding requests to your origin, and removes Set-Cookie headers from responses before returning responses to your viewers.

To make CloudFront keep "Set-Cookie" header, I used following settings:

image

It'll be nice this can be configged directly in cloudformation template.

@justincolangelo
Copy link

Is there something that can or should be done for self-hosted deployments that use Cloudflare?

@maxime-memtell
Copy link

maxime-memtell commented Jun 23, 2022

Hey @wsxiaoys ,
Thanks for the help here, I'm pretty new to all the AWS jazz and it's not obvious to me which distributions I need to do the following changes for.

I had a hard time finding this setting in the first place so for anyone interested, it's in the AWS console, in the CloudFront service, make sure the region matches your needs (should be Global by default though), here there is a list of distributions, select one (which?), then go to the "behaviors" tab, select one (which?), and edit it. And there, in the menu, you will find the settings related to the screenshot from @wsxiaoys .

So here's my question, which distribution do I have to apply that to? And which behaviours? I could imagine the answer is "all" but I don't want to break something by doing so without understanding the implications.

Additional question, the name of the cookie is "not-actually-needed" but it is important to specify one. Does this randomly chosen name have to match across all distributions and behaviours?

Thanks!

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

3 participants