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

+1 -7
View File
@@ -27,12 +27,6 @@
<main>
{% block content %}{% endblock %}
</main>
<script>
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker.register("{% url 'pwa:service_worker' %}");
});
}
</script>
<script src="{% static 'js/register-sw.js' %}" defer></script>
</body>
</html>