Skip to main content
CSP directives for Weaverse Studio, for the request being rendered. Returns {} for normal visitors: outside Studio the browser never contacts Weaverse, so a theme’s policy needs nothing extra. Inside Studio, the Studio origin is allowed to embed the page and serve the bridge, and design mode adds 'unsafe-eval' because the bridge rebuilds schema condition functions from strings. The weaverseHost query is attacker-controllable, so it goes through the same trust check that gates the bridge script: an untrusted host, or a loopback host on a non-loopback storefront, returns {}, as does a relative or malformed URL. Only https:// hosts on weaverse.io or weaverse.dev (or their subdomains) are trusted; without a weaverseHost, the default Studio origin https://studio.weaverse.io is used. A self-hosted or staging Studio on another domain is not trusted, so add that origin to your own directives. Works in both report-only and enforcing policies. React Router storefronts import it from @weaverse/hydrogen/react-router, Next.js storefronts from @weaverse/hydrogen/next/server. The example below needs @shopify/hydrogen 2026.10.3 or later, the first release with createContentSecurityPolicy.
Append Studio’s sources to the theme’s own instead of assigning them: overwriting scriptSrc drops sources such as 'unsafe-inline' inside Studio.

Parameters

string | Request | URL
required

Returns

WeaverseStudioCspDirectives