Hubs-Foundation / hubs-cloud

Resources for self hosted Hubs Cloud instances
Mozilla Public License 2.0
149 stars 89 forks source link

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

Open wsxiaoys opened 2 years ago

wsxiaoys commented 2 years ago

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 commented 2 years ago

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

maxime-memtell commented 2 years ago

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!