Skip to content

Commit

Permalink
🐛 fix csp for local env not recognizing localhost a valid
Browse files Browse the repository at this point in the history
  • Loading branch information
michenly committed Dec 21, 2023
1 parent f0415c9 commit f4f3ed2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-hotels-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/hydrogen': patch
---

🐛 fix content security policy for local enviorment for not recognizing localhost asset server as a valid policy
6 changes: 3 additions & 3 deletions packages/hydrogen/src/csp/csp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ function createCSPHeader(

// Support localhost in development
if (process.env.NODE_ENV === 'development') {
defaultDirectives.styleSrc = [...styleSrc, 'localhost:*'];
defaultDirectives.defaultSrc = [...defaultSrc, 'localhost:*'];
defaultDirectives.styleSrc = [...styleSrc, 'http://localhost:*'];
defaultDirectives.defaultSrc = [...defaultSrc, 'http://localhost:*'];
defaultDirectives.connectSrc = [
...connectSrc,
'localhost:*',
'http://localhost:*',
// For HMR:
'ws://localhost:*',
'ws://127.0.0.1:*',
Expand Down

0 comments on commit f4f3ed2

Please sign in to comment.