Solved

CSP Violation Error when Adding Google Fonts to Shopify Hydrogen 2.0

kiran121
Shopify Partner
4 0 3

How can I resolve this CSP violation error on Shopify Hydrogen 2.0 and successfully add Google Fonts to my theme? I've attempted to update the style-src directive with the Google Fonts URL, but the issue persists. Any insights or guidance on adjusting the CSP settings for the Hydrogen 2.0 theme would be greatly appreciated.

Thanks in advance!

Accepted Solution (1)

Weaverse
Shopify Partner
50 15 21

This is an accepted solution.

Hey @kiran121, you can update the createContentSecurityPolicy function in entry.server.tsx file to include "fonts.googleapis.com". However, this function does not merge the directives by default. You have to define all other styleSrc directives like this.

Helping merchants build super unique, high-performance storefronts using Weaverse + Hydrogen.
Looking for Development & Agency partners.
If you find the answer helpful, give it a thumbs up!
Our App: Weaverse Hydrogen Theme Customizer

View solution in original post

Replies 3 (3)

Weaverse
Shopify Partner
50 15 21

This is an accepted solution.

Hey @kiran121, you can update the createContentSecurityPolicy function in entry.server.tsx file to include "fonts.googleapis.com". However, this function does not merge the directives by default. You have to define all other styleSrc directives like this.

Helping merchants build super unique, high-performance storefronts using Weaverse + Hydrogen.
Looking for Development & Agency partners.
If you find the answer helpful, give it a thumbs up!
Our App: Weaverse Hydrogen Theme Customizer
kiran121
Shopify Partner
4 0 3

Thank you , it works

denis1234
Shopify Partner
1 0 0

its not working for me btw