From e77be0ac3f3557bc9aac528bf1c4ac5eb4b3030d Mon Sep 17 00:00:00 2001 From: Boris Kurktchiev Date: Sat, 12 Sep 2026 19:38:49 -0400 Subject: [PATCH] web: an unknown path redirects to the root instead of serving a shell that cannot load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The app routes behind the hash (/#/plan, /#/history …), so a path is never a screen, and the shell's asset URLs are relative (vite base './' — the Pages demo lives under /demo/). nginx's SPA fallback served index.html AT the requested path: for /plan/r/x (a typo, a stale link, anything not a file) the page's scripts resolved to /plan/r/assets/… and 404'd — a blank page with a 200. try_files now ends in a named location that answers 302 / (query string kept; the hash never reaches the server). absolute_redirect off keeps the Location relative, so the redirect stays on whatever scheme and host the reverse proxy in front presented instead of nginx's own http://host:80. Files, directories, /api/ and the regex locations are untouched. Co-Authored-By: Claude Fable 5.1 (cherry picked from commit e49f1326e2c2c63c6688dfe85fc3e4bdd444231f) --- web/nginx.conf.template | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/web/nginx.conf.template b/web/nginx.conf.template index c44f5ff..2cd22ad 100644 --- a/web/nginx.conf.template +++ b/web/nginx.conf.template @@ -53,9 +53,18 @@ server { proxy_set_header CF-Connecting-IP "${CF_CONNECTING_IP}"; } - # SPA fallback + # The app routes behind the hash (/#/plan, /#/history …), so a path is never a screen, and the + # shell's asset URLs are relative (vite base './' — the Pages demo lives under /demo/). Serving + # index.html AT a deep path (/plan/r/x: a typo, a stale link) gave a page whose scripts resolved + # under that path and 404'd — blank, with a 200. Send the browser to the root instead. The + # query string travels along; the hash never reaches the server anyway. Relative Location so + # the redirect keeps the scheme and host the reverse proxy in front presented, not nginx's own. location / { - try_files $uri $uri/ /index.html; + try_files $uri $uri/ @root; + } + location @root { + absolute_redirect off; + return 302 /$is_args$args; } # App shell: always revalidate so updates show up immediately