Skip to content

[Bugfix #269] Bundle vendor libraries locally to fix CSP-blocked document viewer#270

Merged
waleedkadous merged 1 commit into
mainfrom
builder/bugfix-269-af-open-document-viewer-fails-
Feb 15, 2026
Merged

[Bugfix #269] Bundle vendor libraries locally to fix CSP-blocked document viewer#270
waleedkadous merged 1 commit into
mainfrom
builder/bugfix-269-af-open-document-viewer-fails-

Conversation

@waleedkadous
Copy link
Copy Markdown
Contributor

Summary

Fixes #269

The document viewer (open.html) loaded PrismJS, marked, and DOMPurify from external CDNs (cdnjs.cloudflare.com, cdn.jsdelivr.net). When served through Codev Cloud, the Content Security Policy blocks these external scripts, causing:

  • Blank content area in the document viewer
  • Prism is not defined errors in console
  • CSP violation warnings for blocked scripts and stylesheets

Root Cause

The page's CSP (set by the cloud infrastructure) restricts script-src and style-src to 'self' and 'unsafe-inline', blocking all external CDN domains.

Fix

  • Bundled PrismJS (core + 9 language components + theme CSS), marked.js, and DOMPurify locally under templates/vendor/
  • Added a vendor/* sub-route to the annotate handler in tower-routes.ts to serve these files with correct MIME types and caching headers
  • Updated open.html to reference local vendor paths instead of CDN URLs
  • Added path traversal protection and file extension validation on the vendor route

Test Plan

  • Added 5 regression tests for the vendor route (JS content type, CSS content type, path traversal block, 404 for missing files, disallowed extensions)
  • All 27 tower-routes tests pass (22 existing + 5 new)
  • TypeScript type check passes
  • Build succeeds
  • No external CDN references remain in open.html

…void CSP blocks

The document viewer (open.html) loaded PrismJS, marked, and DOMPurify
from external CDNs. When served through Codev Cloud, the Content
Security Policy blocks these external scripts, causing a blank content
area and "Prism is not defined" errors.

Bundles all vendor libraries locally under templates/vendor/ and adds
a vendor sub-route to the annotate handler to serve them. This removes
all external CDN dependencies from the document viewer.
@waleedkadous waleedkadous merged commit d891d7a into main Feb 15, 2026
7 checks passed
@waleedkadous waleedkadous deleted the builder/bugfix-269-af-open-document-viewer-fails- branch February 15, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

af open document viewer fails to render — Prism not defined (CSP blocks external scripts)

1 participant