-
Notifications
You must be signed in to change notification settings - Fork 303
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
💥 custom CSP will always extend Shopify domain and default development domain #1593
Conversation
6285264
to
f6ab545
Compare
f6ab545
to
463e551
Compare
I am pretty sure there are many more docs I need to update. Will figure it out soon! |
.changeset/heavy-coins-tickle.md
Outdated
'@shopify/hydrogen': patch | ||
--- | ||
|
||
✨ add applyDefault option to createContentSecurityPolicy which allow use to add policy in front of the existing rules instead of overriding them. The default value of applyDefault option is false which is the current behaviour. |
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.
✨ add applyDefault option to createContentSecurityPolicy which allow use to add policy in front of the existing rules instead of overriding them. The default value of applyDefault option is false which is the current behaviour. | |
✨ add `applyDefault` option to `createContentSecurityPolicy` which automatically adds Shopify domains to the content security policy, extending whatever rules are passed instead of overriding them. The default value of `applyDefault` option is false which is the current behavior. |
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.
Actually thinking about this more, I think almost always if the user provides a custom CSP, they will probably also want to keep the Shopify domains as well. So perhaps this should be default to true
, or inverse it and default it to false
. Sure it would be a breaking change, but it's relatively minor, and we can make a breaking change for the 2024-01 release. So now would be the time to do it. Thoughts?
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.
@blittle 👍 true say. Since including Shopify domains really just allow more CSP, nothing should really break.
I will edit and make this PR a breaking change and use extending as the default.
Co-authored-by: Bret Little <[email protected]>
93afc58
to
3c73e90
Compare
3c73e90
to
3f88fbd
Compare
WHY are these changes introduced?
The CSP bug was found when using ngrok as public domain for local development (after #1591)
Without modifying anything you will find the following bug in browser

The fix for this is to modify
createContentSecurityPolicy
options inapp/entry.server.tsx
which the user need to add in the public domain they are using follow by all the current defaults manually.This is not easy to maintain, specially if the defaults ever change.
WHAT is this pull request doing?
This PR change the behaviour of
createContentSecurityPolicy
where the custom CSP pass in will no longer override the default domains.The new behaviour will take the user generated options and add default policies on top of it.
HOW to test your changes?
Post-merge steps
Checklist