Repository navigation
Description
Summary
In the opencode v2 web/desktop UI, previewing a .pdf or .html file from the file tree shows the browser block page "已阻止此内容。请与网站所有者联系以解决此问题。" ("This content is blocked. Contact the site owner to fix the issue.") instead of the file. The file itself is fine — the same file opens normally in an external viewer/browser. The cause is the server's Content-Security-Policy, which governs frame-src/object-src via default-src 'self' and does not allow blob: for frames/objects, while the preview renders those files from a blob: URL.
Environment
- opencode version: 2.0.26 (V2; npm package
@opencode/[email protected], isolated prefix) - OS: Linux 6.18.40.1-microsoft-standard-WSL2 (WSL2), x86_64; Windows 11 host
- Terminal: Unavailable: not applicable — reported in the web UI (server
opencode serve --hostname 0.0.0.0 --port 4098) - Shell: /bin/bash
- Install/channel: release/latest, installed via npm into an isolated prefix (
/opt/opencode-v2) - Active plugins: none declared in the V2 config (
/var/lib/opencode-v2/config/opencode/opencode.jsonchas noplugin/mcpkeys)
Reproduction
- Start the v2 server:
opencode serve --hostname 0.0.0.0 --port 4098. - Open the web UI (e.g.
http://127.0.0.1:4098/) and open a workspace with a.pdfand an.htmlfile (any valid file works). - In the file tree, open/preview the
.pdf(and separately the.html).
Expected Behavior
The preview renders the PDF / HTML content inline.
Actual Behavior
The preview area shows the browser block page: "已阻止此内容。请与网站所有者联系以解决此问题。" Other types (.md, .txt, code, images, .csv) preview fine. The same PDF/HTML opens fine in an external browser/viewer, so the files are valid and only the in-app preview is affected.
Additional Context
Every response from the v2 server carries this CSP header (verified with curl -D- http://127.0.0.1:4098/):
content-security-policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval' 'sha256-...'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: blob:; font-src 'self' data:; media-src 'self' data:; connect-src * data: blob:; worker-src 'self' blob:
Observations:
- There is no explicit
frame-srcorobject-src, so both fall back todefault-src 'self'. blob:is whitelisted only forimg-src,connect-src, andworker-src— not forframe-src/object-src.- PDF and HTML previews must use a framed/embedded element (
<iframe>/<embed>/<object>), and the frontend builds ablob:URL from the file bytes (URL.createObjectURL(new Blob([...], { type: <mime> }))). Underdefault-src 'self', Chromium refuses to frame ablob:URL, producing the blocked-content page above.
Consistent with this: types that render as DOM (markdown/text/code) or via img-src (images, which do allow blob:) work; only PDF/HTML (frame/object) are blocked.
Suggested fix: add blob: (and likely data:) to the frame/object source policy, e.g. frame-src 'self' blob:; object-src 'self' blob: (or allow blob: in default-src).
Frequency: reproducible every time for .pdf and .html.
Activity
opencode-agent commentedon Oct 10, 2026
Thanks for the detailed report and the CSP analysis. I think this is a duplicate of #50828. That issue covers the same missing
frame-src/object-srcin the v2 web UI CSP, which blocksblob:iframes with "This content is blocked", and its comments confirm that HTML and PDF file previews are affected.Possible duplicates and related items, ordered by likelihood:
frame-src, soblob:frames fall back todefault-src 'self'). Comments report the HTML/PDF preview case on 2.0.16–2.0.22.v2that addsframe-src 'self' blob:; object-src 'self' blob:topackages/cli/src/services/web-ui.ts, which is the fix you suggested.devbranch.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. Adding your 2.0.26 data point to #50828 would help show the problem is still present.
opencode-agent commentedon Oct 11, 2026
Closing this as a duplicate of #50828. We waited a day for a reply explaining how this is different and didn't get one. Both issues have the same cause: the web UI CSP has no
frame-src/object-src, so the PDF/HTML preview'sblob:iframe is blocked with "This content is blocked".Please follow #50828 for updates. The proposed fix is in #52948, which adds
frame-src 'self' blob:; object-src 'self' blob:. Adding your 2.0.26 data point there would help. If your problem turns out to be different, reply here and we can reopen. Thanks again for the thorough write-up.