Serve security headers via static-web-server, drop Cloudflare deploy path

Production (Dokploy/Docker) was sending no security headers at all -
static/_headers and wrangler.toml were Cloudflare Pages/Workers
config that static-web-server never reads. Added sws.toml with the
same CSP/security headers and the two redirects from _redirects,
wired into the Dockerfile. Removed wrangler.toml, static/_headers,
static/_redirects, the wrangler devDependency/deploy script, and
related .gitignore/.dockerignore entries since Cloudflare deploy is
no longer used.

Also fixed a console error in theme.js where the Utterances
postMessage call could fire before the comments iframe navigated to
utteranc.es.
This commit is contained in:
2026-08-19 12:31:44 +03:00
parent a49aa02886
commit f87b818201
11 changed files with 35 additions and 1589 deletions
-7
View File
@@ -1,7 +0,0 @@
/*
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://www.googletagmanager.com https://utteranc.es https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://www.google-analytics.com; font-src 'self'; connect-src 'self' https://www.google-analytics.com https://cloudflareinsights.com; frame-src https://www.youtube-nocookie.com https://utteranc.es; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=(), interest-cohort=()
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
-2
View File
@@ -1,2 +0,0 @@
/security.txt /.well-known/security.txt 301
/index.xml /rss.xml 301
+7 -1
View File
@@ -58,7 +58,13 @@ document.addEventListener('DOMContentLoaded', () => {
const theme = htmlElement.classList.contains('dark')
? commentsEl.dataset.utterancesThemeDark
: commentsEl.dataset.utterancesThemeLight;
frame.contentWindow.postMessage({ type: 'set-theme', theme }, 'https://utteranc.es');
// The iframe briefly shares our origin before it navigates to utteranc.es,
// so posting with that targetOrigin throws until the navigation completes.
try {
frame.contentWindow.postMessage({ type: 'set-theme', theme }, 'https://utteranc.es');
} catch (e) {
// Ignore: frame hasn't navigated to utteranc.es yet.
}
};
new MutationObserver(syncUtterancesTheme).observe(htmlElement, {
attributes: true,