Skip to content

Node host ​

Guide draft deployment node hosting login

Run the XYZ Express app as a long-lived server on your own Node host, and configure cookies and redirects when one XYZ instance handles login for others.

Resource and sources

server.js calls app.listen(xyzEnv.PORT) whenever VERCEL is unset, so the same entry point runs as a long-lived server.[1] The repository has no Dockerfile; containerising it follows the same steps.[2]

A checkout of main or a release tag carries the MAPP bundles. On another branch, build them first with a full pnpm install; the Vite build tools are dev dependencies, which --prod does not install. See release builds.

bash
pnpm install --prod
pnpm exec varlock run -- node apps/xyz/server.js   # with Varlock
node apps/xyz/server.js                            # environment from the host
  • Under varlock run, .env and .env.schema resolve at process start, so gsm() references need credentials on the host, and a restart picks up new secret versions. See Vercel environment.
  • PORT defaults to 3000. Put a TLS-terminating proxy in front; the default cookies are Secure.
  • Set XYZ_CWD when the working directory is not the repository root, so resources, *.pem and file: workspace references resolve.
  • A normal install builds the native bcrypt module, which password login needs; --ignore-scripts skips it.
  • The same smoke routes apply as on Vercel.

One XYZ instance for login ​

When one instance, eg. an admin instance, handles login for others:

  • COOKIE_PROPS. Instances on subdomains (admin.example.com, mapp.example.com) need Domain=.example.com, eg. COOKIE_PROPS="Secure; HttpOnly; SameSite=Strict; Domain=.example.com; Path=/". Instances on paths of one domain (example.com/admin, example.com/demo) need no change; the default omits Domain and derives Path from DIR.[3]
  • TRUSTED_RETURN_HOSTS. Only the subdomain layout needs it, since its return_to is an absolute URL, eg. TRUSTED_RETURN_HOSTS=https://admin.example.com. Unset, no absolute return_to is accepted. See TRUSTED_RETURN_HOSTS.
  • JWT_ISSUER and JWT_AUDIENCE. The iss and aud claims of the session token, both xyz by default. See session token claims.

  1. apps/xyz/server.js. ↩︎

  2. DEPLOYMENT.md, "Your own Node host" and "Using XYZ for login". ↩︎

  3. apps/xyz/mod/utils/processEnv.js COOKIE_PROPS default. ↩︎

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.