Fix admin login behind HTTPS: configurable public URL scheme/port #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "session/polish"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes the admin login failing in production with "Cross-site POST form submissions are forbidden".
ORIGIN,PUBLIC_POCKETBASE_URLandPUBLIC_SITE_URLwere hard-coded tohttp://<sub>.${DOMAIN}:8080. The live site is served ashttps://<sub>.ewashafik.reudy.netby a TLS reverse proxy in front of this stack, so SvelteKit's CSRF check rejected the login form (the browser's origin didn't matchORIGIN). Image URLs built fromPUBLIC_POCKETBASE_URLalso pointed at the unreachable:8080.URL_SCHEME(defaulthttp) andURL_PORT(default:8080, empty = no port) build all three URLs. Defaults are unchanged, so local dev is unaffected.${A:-${B}}defaults (tested)..env.example, README (Deploying behind HTTPS) and AGENTS.md.Production
.env:Verified with
podman-compose configfor both the default and the HTTPS settings.Update: reproduced the 403 against production:
URL_PORTwasn't set there, so it defaulted to:8080(ORIGIN=https://admin.ewashafik.reudy.net:8080). RecommendURL_PORT=:443(non-empty, normalised away by adapter-node).PUBLIC_*URLs now go throughbaseUrl()so saved image URLs and email links never carry a default port.🤖 Generated with Claude Code
https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
ORIGIN, PUBLIC_POCKETBASE_URL and PUBLIC_SITE_URL were hard-coded to http://<sub>.${DOMAIN}:8080. Behind a TLS reverse proxy the browser's origin is https://<sub>.<domain>, so SvelteKit rejected the admin login form ("Cross-site POST form submissions are forbidden") and image URLs pointed at an unreachable port. URL_SCHEME / URL_PORT now build them (defaults unchanged). Two flat variables because podman-compose 1.5 does not support nested ${A:-${B}} defaults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv