Space Works Inventory · Install and run

Netlify frontend with a Docker VPS backend

Documentation index · VPS installation

The frontend/ workspace builds a rendering-only copy of the website. Authentication, permissions, tenant queries, photos, Server Actions, payments and background jobs run on the backend. The same frontend image also runs in the installer's two-hostname VPS layout (split); this guide covers both that and a website on Netlify (installer layout 3, netlify).

Host Runs
inventory.example.org, Netlify or the frontend container Pages, thin Server Actions, same-origin /api/* proxy
api.inventory.example.org, backend container Guarded view and action gateway, Auth.js, REST API, payment webhooks and photos
Private Docker network TLS PostgreSQL, authenticated TLS Redis, private Silo storage, worker and beat

Current limitations

Read this before choosing a split layout:

  • Page coverage. The website build renders every page (frontend/pages.json, generated by npm run frontend:catalog, covers sign-in, setup, account, instance admin, every page inside a space, the /q/<code> QR landing and the public catalogue), and the resource allowlist (lib/frontend/resources.ts) proxies CSV exports, label printing and import error downloads to the backend. npm run test:e2e:split -- --external-services --demo runs every signed-in journey through the website and gateway.
  • Payment webhooks. Payments settings show webhook URLs on NEXT_PUBLIC_BASE_URL, the website. The website's /api/* proxy refuses cross-origin POSTs that carry no bearer token and does not forward the x-razorpay-signature or stripe-signature headers, so a provider calling the website gets 404. In a split layout, register the API hostname instead: take the URL the app shows and replace its host, for example https://api.inventory.example.org/api/payments/razorpay/<code>. The backend serves /api/* directly in this mode.

Netlify settings

Choose 3 in the curl installer. Point the API A/AAAA records at the VPS; point the website records at Netlify. Keep both hosts on the same reviewed revision. AUTH_URL and NEXT_PUBLIC_BASE_URL on the backend name the website. First-run setup is /setup on the website.

Set Package directory = frontend, leave Base directory = repository root, and select frontend/netlify.toml. It uses Node 22, runs npm run build:frontend and publishes frontend/.next. Use Netlify's Next.js adapter; no static export. Copy these values from the generated owner-only frontend.env into Netlify's build and functions/runtime environment, without Compose's surrounding quotes:

Variable Value
NEXT_PUBLIC_BASE_URL Exact website HTTPS origin
BACKEND_ORIGIN Exact backend HTTPS origin
NEXT_PUBLIC_BACKEND_ORIGIN The same backend origin (the frontend refuses to start when the two differ)
FRONTEND_GATEWAY_SECRET Independent random 32-byte hex peer key, the same on the backend
FRONTEND_TRUSTED_IP_HEADER x-nf-client-connection-ip on Netlify; x-real-ip behind Caddy
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY Independent stable frontend key, at build and runtime

The frontend has no database, Redis, Auth.js signing, mail, storage, MFA or integration encryption credentials. Restrict production credentials to the canonical production deploy; previews use their own backend and secrets.

Gateway and authentication

frontend/catalog.json is the fixed allowlist of guarded page readers and Server Actions. Generated readers run the original page's authentication and space checks (requireSpace, MFA step-up for /admin) on the backend. The peer credential identifies a server; it grants no user or tenant role. The backend forwards no permission claims from a browser. Views accept only bounded route and query values. DTOs omit persistence secrets; the handler rejects secret fields again. Actions keep their validation, audit, rate limits and transactions. Invalidations and local redirects return to the frontend. Response cookies stay host-only on the website.

npm run frontend:catalog regenerates the contracts when pages or actions change; review and commit the result. npm run frontend:prepare makes the ignored rendering tree. Builds reject database, Redis, mail and object-storage clients in deployment traces. Edit root sources and frontend templates, never generated frontend files.

Browser /api/* requests use the website origin and are proxied to the backend. Internal jobs, authenticated readiness and the private gateway routes answer 404 there. /api/v1 requests with an API key (Authorization: Bearer) pass through; webhook senders and monitors should target the backend hostname directly. Keep payment signatures, API keys and cron bearers intact; gateway trust never replaces those checks.

Verify and update

Through the website, exercise setup, sign-in with a password, a magic link, invitation, password reset, two-step verification, /admin, and cross-tenant denial; then the acceptance checklist for the pages the website build covers. Verify that internal endpoints stay unavailable on the website. Check both HTTPS names and the backend operator checks. Test SMTP and a restore in the real hosting environment. Netlify plan duration and upload limits still apply.

Update the backend through the installer, then deploy the identical revision on Netlify. Preserve the gateway key and each host's own Server Actions key. Hostname changes require DNS, canonical URLs, payment webhook URLs and a frontend redeployment; release containers apply their public origins at start. Keep redirects for old invitation links and printed QR labels.

For isolated CI verification, npm run test:e2e:split builds both production servers with separate action keys and disposable dependencies. Do not run the Docker and browser suite on a memory-constrained development machine.

Worker and beat run from the backend image on the VPS with backend runtime settings. They expose no public routes; Netlify receives no Redis or job-processing credentials. See Production operations.

From SpaceWorks-Inventory/docs/DEPLOYMENT_SPLIT.md at ff466bc, updated 2026-10-29. Suggest a change