diff --git a/Caddyfile.example b/Caddyfile.example deleted file mode 100644 index 740bf8b..0000000 --- a/Caddyfile.example +++ /dev/null @@ -1,15 +0,0 @@ -# Example site block for the existing Caddy container. Caddy has to be attached -# to the external networks "wizard_website" and "wizard_api". -wizard.example.com { - encode zstd gzip - - # Game server: REST + websocket (Caddy proxies websockets automatically). - # /internal/* (AI endpoint) is intentionally not exposed. - handle /api/* { - reverse_proxy wizard_server:8083 - } - - handle { - reverse_proxy wizard_website:8082 - } -} diff --git a/wizard_website/nginx.conf b/wizard_website/nginx.conf index 1e075cb..fb6fac0 100644 --- a/wizard_website/nginx.conf +++ b/wizard_website/nginx.conf @@ -6,12 +6,19 @@ server { # Hashed build assets can be cached forever. location /assets/ { add_header Cache-Control "public, max-age=31536000, immutable"; - try_files $uri =404; + try_files $uri @strip_prefix; } - # Single page app: always serve index.html. location / { add_header Cache-Control "no-cache"; - try_files $uri /index.html; + try_files $uri @strip_prefix; + } + + # The reverse proxy may forward requests with their path prefix + # (e.g. /website/assets/app.js). Drop leading segments until a file + # matches; everything else is the single page app. + location @strip_prefix { + rewrite ^/[^/]+(/.+)$ $1 last; + rewrite ^ /index.html last; } } diff --git a/wizard_website/vite.config.ts b/wizard_website/vite.config.ts index 2e2bf3c..ed2660d 100644 --- a/wizard_website/vite.config.ts +++ b/wizard_website/vite.config.ts @@ -4,6 +4,8 @@ import { defineConfig } from 'vite' // https://vite.dev/config/ export default defineConfig({ plugins: [react()], + // Relative asset URLs, so the app works under any path prefix (e.g. /website/). + base: './', server: { // Forward API requests (including the websocket) to a locally running game server. proxy: {