Duolith docs

Errors E0500 to E0599

E0551 Address of another site the Content-Security-Policy blocks

Message the Content-Security-Policy does not allow what from origin, so browsers would block address

Words in italics are filled in when the compiler reports it, such as the element's name or the list of known ones.

Why

The build knows every address of another site a page writes as text: an image's src, the address given to api(), stream(), httpTransport(), fetch(), new WebSocket() or new EventSource(), and a url() in a stylesheet (a font inside @font-face). Each is checked against the directive that governs it (img-src, connect-src or font-src, or default-src when that one is left out), the way a browser matches sources, so a request the browser would block fails the build instead of failing when someone opens the screen. 'self' never matches an absolute address, since the build cannot know the site's own origin. An address built from data or read from environment() is known only when the app runs and is not checked, and nothing is checked when the policy is off (decision 0150).

How to fix it

Add the address's origin under its directive in duolith.yaml, such as security: content-security-policy: img-src: [https://images.example.com], or use a path on the app's own site, such as /images/cat.png.

In a terminal

duolith explain E0551

Mentioned in