repospace / UI-FIX.md
2Btainment's picture
fix: SPA fallback blocked /space/* (startswith 's') β€” blank white UI
1cfc10d verified
|
Raw History Blame Contribute Delete
1.42 kB

RepoSpace UI fix β€” blank white screen

Date: 2026-10-02 (Europe/Berlin)
Space: https://huggingface.co/spaces/2Btainment/repospace
App: https://2btainment-repospace.hf.space

Symptom

Blank white page when opening session routes (/space/{id}), on refresh after Launch, or any deep link under /space/…. Landing / HTML/JS/CSS loaded; session URL returned JSON {"detail":"Not found"} (browser shows empty white).

Root cause

In backend/app/main.py, SPA fallback excluded paths with:

full_path.startswith(("api/", "api", "s/", "s", "docs", ...))

str.startswith("s") is true for space/..., so the React route /space/:id never received index.html. Hard refresh / direct open β†’ 404 JSON β†’ white UI.

Secondary: / and SPA routes only allowed GET, so HEAD / returned 405 (some probes/proxies use HEAD).

Not the cause: Docker COPY of frontend dist, Vite asset paths, or missing CSS (assets returned 200).

Fix

  1. Match API/proxy by first path segment (api, s, docs, …) β€” never bare startswith("s").
  2. Register / and /{full_path:path} for GET + HEAD.
  3. Regression tests in backend/tests/test_spa_static.py.

Verify

  • GET /space/abc β†’ 200 text/html with #root
  • HEAD / β†’ 200
  • GET /assets/*.js|*.css β†’ 200
  • GET /api/health β†’ 200
  • Space runtime RUNNING and visible dark UI (not white)