Browse Source

fix(static): serve /fonts/*.woff2 — self-hosted Inter font (#1460 follow-up)

  The browser console logged "downloadable font: rejected by sanitizer"
  for inter-latin.woff2 on every load. The #1460 PWA fix added @font-face
  rules pointing at /fonts/inter-latin.woff2 and bundled the woff2 files
  into static/fonts/, but main.py only mounts /assets, /img and /icons as
  static directories. With no /fonts mount, /fonts/*.woff2 fell through to
  the SPA catch-all and returned index.html with 200 OK; the browser's
  OpenType sanitizer rejected the HTML-as-a-font.

  Add a /fonts StaticFiles mount alongside /img and /icons. The woff2
  files themselves are valid (verified — Inter variable, latin and
  latin-ext subsets).

  Also bump the service worker STATIC_CACHE version (v26 -> v27). sw.js
  lists the two font URLs in STATIC_ASSETS, and cache.addAll() treats the
  200 OK HTML as a successful fetch — so it had cached index.html under
  the font URLs and served it cache-first. The version bump makes the
  activate handler purge the poisoned cache and re-fetch the real fonts.
maziggy 5 days ago
parent
commit
16da533c9a
4 changed files with 15 additions and 4 deletions
  1. 1 0
      CHANGELOG.md
  2. 10 0
      backend/app/main.py
  3. 2 2
      frontend/public/sw.js
  4. 2 2
      static/sw.js

File diff suppressed because it is too large
+ 1 - 0
CHANGELOG.md


+ 10 - 0
backend/app/main.py

@@ -5457,6 +5457,16 @@ if app_settings.static_dir.exists() and any(app_settings.static_dir.iterdir()):
             StaticFiles(directory=app_settings.static_dir / "icons"),
             name="icons",
         )
+    # Self-hosted Inter woff2 files (#1460). Without this mount /fonts/*.woff2
+    # falls through to the SPA catch-all and returns index.html, which the
+    # browser's font sanitizer rejects ("downloadable font: rejected by
+    # sanitizer").
+    if (app_settings.static_dir / "fonts").exists():
+        app.mount(
+            "/fonts",
+            StaticFiles(directory=app_settings.static_dir / "fonts"),
+            name="fonts",
+        )
 
 
 @app.get("/")

+ 2 - 2
frontend/public/sw.js

@@ -1,6 +1,6 @@
 // Bambuddy Service Worker
-const CACHE_NAME = 'bambuddy-v27';
-const STATIC_CACHE = 'bambuddy-static-v26';
+const CACHE_NAME = 'bambuddy-v28';
+const STATIC_CACHE = 'bambuddy-static-v27';
 
 // Static assets to cache on install
 const STATIC_ASSETS = [

+ 2 - 2
static/sw.js

@@ -1,6 +1,6 @@
 // Bambuddy Service Worker
-const CACHE_NAME = 'bambuddy-v27';
-const STATIC_CACHE = 'bambuddy-static-v26';
+const CACHE_NAME = 'bambuddy-v28';
+const STATIC_CACHE = 'bambuddy-static-v27';
 
 // Static assets to cache on install
 const STATIC_ASSETS = [

Some files were not shown because too many files changed in this diff