From 1b59b548fafdb7cce195a20f64ab27c50b42b98c Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Wed, 5 Aug 2026 04:32:52 +0200 Subject: [PATCH] caddy --- .forgejo/workflows/deploy.yaml | 2 +- deploy/Caddyfile.example | 24 ++++++++++++++---------- deploy/README.md | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index 1e31b0f..da636fb 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -37,7 +37,7 @@ jobs: nodejs \ clang lld libc++ \ wasi-libc wasi-libc++ wasi-libc++abi wasi-compiler-rt \ - git curl tar rsync zstd gzip jq openssl ffmpeg gnupg + git curl tar rsync zstd gzip jq openssl ffmpeg gnupg cmake # Container runs as root; workspace may be owned by another uid. git config --global --add safe.directory '*' diff --git a/deploy/Caddyfile.example b/deploy/Caddyfile.example index f97d89d..ba78869 100644 --- a/deploy/Caddyfile.example +++ b/deploy/Caddyfile.example @@ -82,16 +82,20 @@ catcrafts.net { handle { reverse_proxy 127.0.0.1:8081 { health_uri /api/healthz - - # If the backend is down, fall back to the static wasm shell so the - # site degrades to a client-rendered app rather than a Caddy 502. - # Content still renders; only real status codes and SSR are lost. - @down status 502 503 504 - handle_response @down { - rewrite * /index.html - header Cache-Control "no-store" - file_server - } } } + + # If the backend is down, fall back to the static wasm shell so the site + # degrades to a client-rendered app rather than a bare Caddy error page. + # This must be handle_errors, not handle_response: handle_response only + # fires on responses an upstream actually sent, and a backend that is not + # running refuses the connection — that is an error, which only + # handle_errors sees (verified against a dead port). The error status is + # kept, so a crawler sees the honest 502 while a human gets the working + # client-rendered app; only SSR and real 404s are lost. + handle_errors 502 503 504 { + rewrite * /index.html + header Cache-Control "no-store" + file_server + } } diff --git a/deploy/README.md b/deploy/README.md index 66d8d32..71a96c8 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -106,7 +106,7 @@ request arriving mid-copy never hits a truncated executable. ## If the backend is down -Caddy's `handle_response @down` falls back to serving the static `index.html`, +Caddy's `handle_errors` fallback serves the static `index.html`, so the site degrades to the client-rendered wasm app rather than showing a 502. Content still renders; what is lost is server-side rendering and real status codes — an unknown path becomes a soft 404 again until the backend returns.