fix(mindspace): guard published pages against blocked CDN scripts

Pre-bundle Chart.js, auto-rewrite common CDN references at publish and serve time, and block unknown external script src during publication scans so interactive dashboards keep working under CSP.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-10 10:27:42 +08:00
parent eea14c1855
commit aede1e6fcb
12 changed files with 392 additions and 5 deletions
+2
View File
@@ -2,6 +2,7 @@ import crypto from 'node:crypto';
import fs from 'node:fs/promises';
import path from 'node:path';
import { localizeGoogleFontsCss } from './mindspace-html-localize.mjs';
import { rewriteKnownCdnScriptSources } from './mindspace-published-script-localize.mjs';
import { replacePrivateResourceReferences, scanContent } from './mindspace-content-scan.mjs';
import { pageInternals, normalizeWorkspaceRelativePath } from './mindspace-pages.mjs';
import { readWorkspacePublishHtml } from './mindspace-workspace-path.mjs';
@@ -352,6 +353,7 @@ async function prepareHtmlPublishContent({
h5Root = null,
}) {
let publishContent = (await localizeGoogleFontsCss(html)).html;
publishContent = rewriteKnownCdnScriptSources(publishContent).html;
publishContent = replaceImgproxyStandardImageReferences(
publishContent,
resolvePublicBaseUrl(),