feat(csp): declare the frame-src sources the preview reference needs#114
Merged
Conversation
The preview block reference embeds a Wikipedia article and an OpenStreetMap map to demonstrate a live preview. Neither host is covered by a consuming site's default CSP, so the browser blocked both iframes and the page rendered two empty boxes on every site shipping this content, including demo.gethinode.com and gethinode.com. Declare the two sources through [params.modules.docs.csp], the same way mod-leaflet declares tile.openstreetmap.org for its own img-src. Consuming sites now inherit them rather than hand-maintaining the list, which is how the two sites drifted apart in the first place. The reference also previews google.com on purpose, to demonstrate a site that refuses to be framed. It sends X-Frame-Options: SAMEORIGIN and cannot be embedded at all, so it needs no frame-src source and correctly falls back to a screenshot. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
🎉 This PR is included in version 1.15.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The preview block reference embeds three sites to demonstrate the component. Two of them require a
CSP
frame-srcsource from the consuming site, and neither was declared anywhere — so the pagerendered two empty boxes on every site that ships this content, including
demo.gethinode.com and
gethinode.com.
frame-srcsource?en.wikipedia.orgwww.openstreetmap.orggoogle.comX-Frame-Options: SAMEORIGINThe google.com preview is intentional: it demonstrates a site that refuses to be framed, and
correctly falls back to a screenshot. It needs no source.
Change
Declare the two sources in
hugo.toml, so consuming sites inherit them:This follows the established pattern — mod-leaflet declares
img-src = ["tile.openstreetmap.org"]for the same reason, and mod-cookieyes declares its own
script-src/connect-src. The module thatembeds a host should declare what it needs.
Right now each site hand-maintains the list instead, which is exactly how the two drifted apart:
gethinode.com had
*.wikipedia.orgbut notwww.openstreetmap.org, so its OpenStreetMap previewwas broken while its Wikipedia one worked.
Verification
Built the hinode exampleSite against this branch (workspace
use), with the site-level entriesremoved, so the sources come only from here:
No CSP warnings. Removing this declaration flips Wikipedia and OpenStreetMap back to a fallback
with a build warning (with gethinode/mod-blocks#152), confirming the sources are what make them
render.
Follow-up
Once this is released, the site-level entries can be dropped from
gethinode/hinode#2008 andgethinode/gethinode.com#154 in favour of a mod-docs bump.🤖 Generated with Claude Code