Fix admin login behind HTTPS: configurable public URL scheme/port #2

Merged
reudy merged 1 commit from session/polish into main 2026-10-07 16:43:42 +02:00
Member

Fixes the admin login failing in production with "Cross-site POST form submissions are forbidden".

ORIGIN, PUBLIC_POCKETBASE_URL and PUBLIC_SITE_URL were hard-coded to http://<sub>.${DOMAIN}:8080. The live site is served as https://<sub>.ewashafik.reudy.net by a TLS reverse proxy in front of this stack, so SvelteKit's CSRF check rejected the login form (the browser's origin didn't match ORIGIN). Image URLs built from PUBLIC_POCKETBASE_URL also pointed at the unreachable :8080.

  • New URL_SCHEME (default http) and URL_PORT (default :8080, empty = no port) build all three URLs. Defaults are unchanged, so local dev is unaffected.
  • Two flat variables because podman-compose 1.5 doesn't support nested ${A:-${B}} defaults (tested).
  • Documented in .env.example, README (Deploying behind HTTPS) and AGENTS.md.

Production .env:

DOMAIN=ewashafik.reudy.net
URL_SCHEME=https
URL_PORT=:443
CADDY_SCHEME=http

Verified with podman-compose config for both the default and the HTTPS settings.

Update: reproduced the 403 against production: URL_PORT wasn't set there, so it defaulted to :8080 (ORIGIN=https://admin.ewashafik.reudy.net:8080). Recommend URL_PORT=:443 (non-empty, normalised away by adapter-node). PUBLIC_* URLs now go through baseUrl() so saved image URLs and email links never carry a default port.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv

Fixes the admin login failing in production with **"Cross-site POST form submissions are forbidden"**. `ORIGIN`, `PUBLIC_POCKETBASE_URL` and `PUBLIC_SITE_URL` were hard-coded to `http://<sub>.${DOMAIN}:8080`. The live site is served as `https://<sub>.ewashafik.reudy.net` by a TLS reverse proxy in front of this stack, so SvelteKit's CSRF check rejected the login form (the browser's origin didn't match `ORIGIN`). Image URLs built from `PUBLIC_POCKETBASE_URL` also pointed at the unreachable `:8080`. - New `URL_SCHEME` (default `http`) and `URL_PORT` (default `:8080`, empty = no port) build all three URLs. Defaults are unchanged, so local dev is unaffected. - Two flat variables because podman-compose 1.5 doesn't support nested `${A:-${B}}` defaults (tested). - Documented in `.env.example`, README (Deploying behind HTTPS) and AGENTS.md. **Production `.env`:** ``` DOMAIN=ewashafik.reudy.net URL_SCHEME=https URL_PORT=:443 CADDY_SCHEME=http ``` Verified with `podman-compose config` for both the default and the HTTPS settings. **Update:** reproduced the 403 against production: `URL_PORT` wasn't set there, so it defaulted to `:8080` (`ORIGIN=https://admin.ewashafik.reudy.net:8080`). Recommend `URL_PORT=:443` (non-empty, normalised away by adapter-node). `PUBLIC_*` URLs now go through `baseUrl()` so saved image URLs and email links never carry a default port. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
agent added 1 commit 2026-10-07 16:37:44 +02:00
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
reudy merged commit 13b5f2bbcb into main 2026-10-07 16:43:42 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: reudy-net/domaino#2
No description provided.