A missing URL_PORT defaults to :8080, and deploy panels often can't store
an empty value, so production kept ORIGIN=https://admin.<domain>:8080 and
the admin login still failed with "Cross-site POST form submissions are
forbidden" (reproduced against production). URL_PORT=:443 is non-empty
and adapter-node normalises it away (new URL().origin).
The PUBLIC_* URLs are used verbatim in saved image URLs, email links and
the admin's View link, so they now go through baseUrl(), which drops
default ports and trailing slashes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: 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
The public (internet-facing) app logged in as the PocketBase superuser and
held the Stripe secret key, so any bug in it could become full control of
the database. Baskets, slot holds, Stripe PaymentIntents, the webhook that
creates orders, and the payment-result lookup now run in PocketBase JS
hooks (pocketbase/pb_hooks/shop, routes under /api/shop/*, plus a cron
that releases expired holds every minute).
The public app's routes keep their URLs but only proxy to those routes and
manage the basket cookie; it has no PocketBase or Stripe secret. Booking
emails are still rendered and sent by the public app (same renderer as the
admin preview) from order data the webhook hook returns; it records the
outcome via a narrow endpoint guarded by INTERNAL_API_SECRET.
Also: slot add and order creation are now transactional; shop listings
load anonymously (already public via API rules); shop API errors always
reach the browser as JSON; the superuser client and stripe package are
removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
`spectado/pocketbase:latest` meant any rebuild could silently jump
versions, while pb_schema.json and the JS migrations target 0.23's format
and API. 0.23.12 is the image `latest` currently resolves to (same image
id), so this changes nothing at runtime.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
Security:
- PocketBase's default `users` collection allows anonymous sign-up, and
every CMS rule only checks "signed in" (the admin login also accepts
`users`). Anyone could register via the public API and edit the site,
read orders/customer details, or log into the admin. Sign-up is now
superuser-only.
- orders.create, baskets.create/update and basket_lines.create/update/
delete were open to anonymous requests, allowing forged "paid" orders in
the admin and basket tampering. The public app performs all of these
server-side with the admin client, so they are now superuser-only
(basket add-item/add-slot verified still working).
Data:
- created/updated autodate fields on all app collections; orders are now
listed newest-first by date (ids are random, '-id' was not chronological).
- Unique indexes on pages.slug and globals.key (skipped with a log line if
existing data has duplicates, so PocketBase still starts).
Delivered as a JS migration in pocketbase/pb_migrations, mounted into the
container (the image already passes --migrationsDir=/pb_migrations), so it
applies once on the next start. pb_schema.json carries the same changes for
fresh installs, where the migration runs before the schema is imported.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
- Auth cookie was always exported with the SDK default `Secure` flag, so
browsers dropped it over plain HTTP (CADDY_SCHEME=http) and login
looped back to /login. Set `secure` from the real request scheme.
- Logout never ran: the hook redirected every authenticated request to
/login (including POST /login?/logout) back to /pages. Only redirect GET.
- Refresh the token per request so revoked tokens log the user out instead
of surfacing as 500s, and sessions slide instead of expiring mid-edit.
- Use `_superusers` instead of the deprecated `pb.admins` alias; keep the
entered email on a failed login.
- docker-compose: fully-qualified image names (podman rejects short names).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv