Skip to content

Deploy to Vercel ​

Guide draft deployment vercel serverless

How the Express app runs as a Vercel function, what a deployment ships, and how to deploy, check, roll back and deploy the auth and SAML apps; use before any Vercel deployment.

Resource and sources

Vercel is the primary deployment target. The Express app runs as one Node serverless function. Configure its environment as described in Vercel environment; for other hosts see Node host.[1]

Prerequisites ​

  • Node 22+ and the pnpm version of the root packageManager.
  • The Vercel CLI, installed globally; it is not a repository dependency: npm install --global vercel or pnpm add -g vercel.
  • vercel login, and a project linked with vercel link, which writes the gitignored .vercel/project.json. A free Hobby account works; XYZ needs no framework preset, so the project defaults can be kept.[2]

How it is wired ​

The root vercel.json builds apps/xyz/server.js with @vercel/node, ships .varlock.blob, public/** and resources/** through includeFiles, and routes /(.*) to the function.[3] The v4 api/api.js entry and the per-endpoint rewrites are gone.

  • No build command runs on Vercel. The MAPP bundles in public/js/lib, public/css/mapp.css and public/css/ui.css upload from the local working tree. They are gitignored on the development branches, so build them first unless deploying from main or a release tag, see release builds.
  • server.js skips app.listen() when VERCEL is set and exports the app for @vercel/node.[4]
  • DIR prefixes every route; the catch-all route needs no change.

What ships ​

@vercel/node traces imports from apps/xyz/server.js. A file read from disk at runtime must be in includeFiles. .vercelignore excludes .env*, *.md, apps/mapp, apps/ui, apps/xyz/tests, packages/devdb and packages/testhost, so pnpm on Vercel never installs PGlite.[5]

Runtime file reads resolve from XYZ_CWD or the repository root:

VariableFile read
SECRET_KEYthe path set, unless the value is the PEM itself
SIGN_<KEY><KEY>.pem
KEY_CLOUDFRONTthe matching *.pem
FILE_RESOURCES (default resources)resource files, not publicly served
WORKSPACE=file:...the workspace JSON

*.pem files are gitignored and upload from the working copy; add them to includeFiles when SECRET_KEY, SIGN_* or KEY_CLOUDFRONT use one. A SECRET_KEY value starting with -----BEGIN is the key itself, eg. from a secret manager, and needs no file.[6]

Deploy ​

bash
pnpm deploy:vercel --env=production   # build, rotate key, freeze blob, deploy
pnpm deploy:vercel --env=preview
vercel --prod                         # without a blob, after a build
vercel --target=preview

utils/deploy-vercel.js builds the bundles, generates a key, freezes .varlock.blob, stores _VARLOCK_ENV_KEY in the target environment, then deploys.[7] Details and the other configuration options are in Vercel environment.

Each deployment gets its own URL; the project domain is on the Overview tab. .vercel/project.json links the folder to one project; run vercel link again, or remove .vercel, to deploy to another project.

Check, roll back, promote ​

bash
vercel ls
vercel inspect <deployment-url>
vercel logs <deployment-url> --follow
vercel rollback                    # previous production deployment
vercel promote <deployment-url>    # promote a validated preview

Smoke routes: /, /api/workspace/locale and /public/js/lib/mapp.js, prefixed with DIR. promote re-points the production alias without a rebuild. Each deployment carries its own blob and key, so a key rotation does not break older deployments. Confirm a rollback serves traffic in the logs.

The auth and SAML apps ​

apps/auth and apps/saml import the XYZ app and mount more routes. Their vercel.json paths are relative to the repository root, so deploy from the root:

bash
pnpm build --filter=@geolytix/mapp --filter=@geolytix/mapp-ui
vercel --prod --local-config=apps/saml/vercel.json

Deploy each to its own Vercel project; every config claims /(.*). The SAML config ships the gitignored apps/saml/*.crt, apps/saml/*.pem and, for a SECRET_KEY file, apps/xyz/*.pem from the working copy. An invalid SAML configuration fails every request.

Headers ​

Response headers, eg. Cache-Control and a Content-Security-Policy, go in a headers array in vercel.json; the repository config has none. The browser console reports resources a CSP blocks. Derive a policy from the sources a workspace loads.

Continuous deployment ​

No workflow deploys the app, and Vercel Git integration deploys a checkout without the bundles. Deploy with pnpm deploy:vercel, or from a workflow which builds first, see Vercel environment.


  1. DEPLOYMENT.md, folded into this and the linked concepts. ↩︎

  2. Wiki VERCEL page. ↩︎

  3. vercel.json. ↩︎

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

  5. .vercelignore. ↩︎

  6. apps/xyz/mod/utils/processEnv.js SECRET_KEY handling. ↩︎

  7. utils/deploy-vercel.js. ↩︎

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