Netlify Deployment
Spine deploys as a single Netlify site: a Vite-built SPA in dist/ plus a flat directory of functions in .assembled/netlify/functions, backed by a Supabase (Postgres) project. Both halves are produced by the same build command — there is no separate function deploy step.
netlify.toml anatomy
The root netlify.toml is partly framework-owned (regenerated on npx spine-framework upgrade, preserving [functions."custom_*"] sections):
| Block | Contents |
|---|---|
[build] | command = "npm run assemble && npm run build", publish = "dist", functions = ".assembled/netlify/functions" |
[build.environment] | SECRETS_SCAN_OMIT_KEYS whitelists the intentionally-public vars (VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY, APP_BASE_URL, SITE_URL, …) so Netlify's secrets scanner does not flag them; SECRETS_SCAN_OMIT_PATHS covers .framework/.xenv* |
[functions] | directory = ".assembled/netlify/functions", included_files for _shared/**, node_bundler = "esbuild", external_node_modules = ["typescript"] (the esbuild printer panic workaround — typescript.js ships unbundled) |
[dev] | netlify dev runs scripts/netlify-dev-wrapper.sh, site on 8888, Vite targetPort 3001, startTimeout 300 |
[functions."<name>"] | per-function config: trigger-scheduler gets schedule = "* * * * *"; ai-agents, kb get timeout overrides |
[[redirects]] | /* → /index.html with status 200 (SPA fallback). Path/host redirect rules go in .framework/public/_redirects instead — Netlify processes _redirects before netlify.toml, so the file's own catch-all would shadow anything here |
[[headers]] | X-Frame-Options DENY, nosniff, HSTS, Referrer-Policy, Permissions-Policy, and a CSP that allows *.supabase.co (https+wss), challenges.cloudflare.com (Turnstile), and the googletagmanager/google-analytics hosts (GA4 — apps opt in per-host via config.analytics.ga4) |
Dispatched trigger pipelines run as Netlify background functions (pipeline-runner-background): the dispatcher gets a 202 immediately and each run gets the fixed 15-minute background budget — which is why no timeout entry exists for it.
How .assembled/ is produced
npm run assemble (scripts/assemble.sh) runs before every dev start (predev:netlify) and every build (prebuild). It wipes stale dist/, then:
scripts/assemble-functions.shflattens.framework/functionspluscustom/functionsandcustom/apps/*/functionsinto.assembled/netlify/functions. Basename collisions are a hard error naming both sources — Netlify needs one flat dir, so last-wins overwrite is forbidden._quarantineand*-test.ts/*.test.tsare excluded.scripts/assemble-frontend.shcopies.framework/srcas the base layer, eachcustom/apps/<slug>verbatim to.assembled/src/<slug>/, fixes upindex.html, merges.framework/public+ apppublic/dirs into the projectpublic/(same-path collisions are a hard error), copies_redirectsinto.assembled/src/fornetlify dev, and stages the projectspine.config.jsonintopublic/.
config/vite.config.ts then builds with root: .assembled/src, publicDir: public/, build.outDir: dist/ — matching publish = "dist". Never edit .assembled/; it is regenerated freely.
The /api/* URL space
Requests to /api/* are rewritten to /.netlify/functions/:splat:
- Production: the published
_redirectsfile — sourced from.framework/public/_redirects, merged intopublic/at assemble time — carries/api/* → /.netlify/functions/:splat 200, plus/spine.config.jsonpassthrough and the/* → /index.htmlfallback. - Dev: the Vite proxy in
config/vite.config.tsmaps/api/*tolocalhost:8888with the same rewrite.
Because the SPA fallback is /* → /index.html 200, any unmatched URL returns HTTP 200 with HTML — including typos under /api/. A probe that gets HTML instead of JSON is hitting the SPA fallback, not a function.
Environment variables in production
Set these in the Netlify site environment (not in netlify.toml). The full annotated list is Environment Variables;
| Variable | Needed for |
|---|---|
VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY | browser bundle (public by design) |
SUPABASE_URL, SUPABASE_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY | all functions — service-role key is server-only, never VITE_-prefixed |
INTERNAL_INVOKE_SECRET | trigger-dispatched pipelines — unset means queued rows that never run |
APP_BASE_URL | invite links, auth redirects, base_url allowlist |
SCHEDULER_API_KEY | key-gated system-cron/trigger-scheduler invocation |
SITE_URL | CORS Access-Control-Allow-Origin; falls back to Netlify's auto-set URL |
RESEND_API_KEY, EMAIL_FROM | outbound email (invites, notification stages) |
OPENAI_API_KEY | AI stage types, agents, embeddings |
NETLIFY_ACCESS_TOKEN, NETLIFY_SITE_ID | optional — push banned IPs to the edge firewall (security function skips silently without them) |
SUPABASE_DB_PASSWORD is not a function env var — it is used locally by npx spine-framework migrate to connect to Postgres directly.
Deploy checklist
- [ ] Supabase project exists;
SUPABASE_*+VITE_SUPABASE_*vars set in Netlify. - [ ]
INTERNAL_INVOKE_SECRETgenerated (openssl rand -hex 32) if triggers are used;APP_BASE_URL/SITE_URLset to the production origin. - [ ] Migrations applied:
npx spine-framework migrateagainst the production DB (see Migrations). - [ ] Deploy via git push or
netlify deploy --prod— the build command runsassemblethenvite buildautomatically. - [ ] Post-deploy smoke:
/api/system?action=healthand?action=manifestanswer; first registration grantssystem_admin(see Install and first run). - [ ] If timers/triggers are used:
trigger-schedulerticks appear in function logs within a minute; a test record write produces atrigger.firedlog row.
Related
- Declare your environments — the
## Environmentsladder this deploy becomes a rung of - Migrations · Upgrade · Troubleshooting
- Environment Variables · CLI Reference
- Anatomy of an installed project — sealed vs customer trees