Fix CSP blocking the service worker registration and tag colors

script-src 'self' blocks any inline <script> block outright, which would
have silently broken the service-worker registration snippet in base.html
in production — the exact feature this whole project exists to support.
Moved it to static/js/register-sw.js, loaded via <script src>, so script-src
can stay strict with no 'unsafe-inline' exception. style-src needed
'unsafe-inline' regardless, since tag pills set a per-tag color via a
dynamic inline style attribute.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-30 20:11:55 -06:00
1 parent 3f6474ce94
commit 4c20558525
4 files changed
+13 -9

No files matched your search

+6 -1
View File
@@ -35,7 +35,12 @@ CONTENT_SECURITY_POLICY = {
"DIRECTIVES": {
"default-src": ["'self'"],
"img-src": ["'self'", "https:", "data:"],
"style-src": ["'self'"],
# Tag pills render a per-tag color via a dynamic inline style="--tag-
# color: ..." attribute (templates/articles/_article_tags.html etc.),
# so style-src needs 'unsafe-inline'. script-src stays strict with no
# exception — every <script> in the app is loaded from a static file
# (see templates/base.html), none inline.
"style-src": ["'self'", "'unsafe-inline'"],
"script-src": ["'self'"],
"frame-ancestors": ["'none'"],
"base-uri": ["'self'"],