Deploying the three tiers
Put Taskboard on three hosts, a static client, a Node API and Postgres, and see how they find each other and why build-time and runtime settings differ.
Continuous integration for a full-stack repoA local environment with Docker ComposeCalling the API from the client
Deploying the three tiers
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Taskboard deploys as three separate things: static files for the client, a long-running process for the API, and a managed Postgres, each with its own host and its own failure modes.
- The client is built once and ships as files, so a value like VITE_API_URL is baked into the bundle at build time and cannot be changed by editing the server's environment later.
- Server secrets such as the database password belong only in the API host's runtime environment and must never carry the client's public prefix.
- Apply database migrations as an explicit release step before the new API starts, not as a side effect of the API booting.
- After a deploy, check the health endpoint, then one real read through the API, then one real page in a browser, because each proves a different seam.
Three things, three hosts
Locally, docker compose up starts everything and localhost is the answer to every address. Production has no localhost. Taskboard becomes three separate deployments:
| Tier | What it is | What it needs from its host |
|---|---|---|
| Client | A folder of static files from vite build |
Somewhere to serve files fast, a CDN ideally |
| API | A Node process listening on a port | A machine or container that stays running |
| Database | Postgres | Disk, backups, and a private way in |
The core problem is that these three can be on different companies’ infrastructure, and each needs to learn where the others are. Deploying a full-stack app is mostly a job of wiring: who calls whom, over what address, with what credentials.
A common free-tier split is static hosting for the client (Vercel, Netlify, Cloudflare Pages), a web-service host for the API (Render, Railway, Fly.io), and a managed Postgres from the same or another provider. A single VPS running all three with a reverse proxy is the other end of the range, with more control and more to maintain. For a Node-specific lesson on the process itself, see deploying Node applications, and for the client side see deploying a frontend app.
Build time versus runtime
This is the seam that surprises people most, so I checked it by building a small Vite project:
const api = import.meta.env.VITE_API_URL ?? "";
export const secret = import.meta.env.DB_PASSWORD;
VITE_API_URL=https://api.staging.example.com DB_PASSWORD=hunter2 npx vite build
grep -o "api.staging.example.com" dist/assets/*.js # found
grep -c hunter2 dist/assets/*.js # 0
I ran this with Vite 8.3.8 on Node 26. The VITE_-prefixed value was inlined into the JavaScript as a literal string. The unprefixed DB_PASSWORD never appeared: hunter2 occurs zero times in the output. That matches Vite’s documented rule that only VITE_-prefixed variables are exposed to client code (my unused export was also tree-shaken away, so this run alone does not distinguish the two reasons).
Two consequences follow.
- The client’s API URL is chosen when you build, not when the page loads. Staging and production need two builds, each pointing at its own API, or a small runtime config file the page fetches. You cannot “just change the env var” on the static host after the build.
- A secret with the
VITE_prefix is published to the world. Everything in the bundle is readable. Keep the prefix for values that are safe to be public, such as the API’s public URL, and put real secrets only in the API’s runtime environment. The environment variables and secrets lesson goes deeper.
The API is the opposite. It reads process.env at runtime, so you can change a variable in the host’s dashboard and restart without rebuilding.
How the tiers find each other
- Browser to client: a domain pointing at the static host. The next lesson covers domains and TLS.
- Browser to API: the client calls the API’s URL. If that URL is on a different origin, the API must allow it with CORS, as set up in CORS and cross-origin setups. A way to avoid CORS entirely is to have the static host proxy
/api/*to the API, so the browser sees one origin. - API to database: a connection string, usually
DATABASE_URL, set in the API’s environment. Use the host’s private or internal address if it offers one, and require TLS if the database is reached over the public internet.
Mismatches at these three joints cause nearly all first-deploy failures: a client built against localhost, a CORS origin missing, a database that rejects the API’s IP.
A release order that works
- Run migrations against the production database as their own step, using the release command the host provides, or a CI job. Do not let the API run them when it boots. If you have two instances starting at once they race, and a failed migration leaves a half-started app. Migrations changing live schemas have their own rules, covered in zero-downtime deploys and schema changes.
- Deploy the API and wait for it to pass its health check.
- Deploy the client last, so it never calls an endpoint that does not exist yet.
For a first deploy that order hardly matters. It starts to matter the first time you add an endpoint and a client that uses it.
The first check after a deploy
Use three checks, each proving a different seam:
GET /healthreturns 200. The API process is up. (See health checks and graceful shutdown.)GET /api/projects/1/tasksreturns data. The API can reach the database and the schema is applied.- Open the real site, sign in, add a task. The client is built against the right URL, CORS allows it, and cookies work across the real domains.
A health endpoint that only returns { ok: true } proves the first of those and nothing else. Keep it that way for the platform’s restart logic, and do the other two yourself or in a post-deploy smoke test.
Containers or not
A host that accepts a Dockerfile removes most “works locally” differences: the image you tested in CI is the image that runs. Many platforms also build straight from your repository with no Dockerfile. Either is fine. The lesson here is the same: one artifact per tier, built once, configured by environment. See containerizing a backend service if you want the Docker route.
What the video covers
ByteMonk’s “From GitHub to Production in Minutes with Render | React + Node + PostgreSQL” runs about ten minutes and is a year old. By its title it deploys a React, Node and Postgres app from GitHub to Render, which matches Taskboard’s three tiers on a single platform. I could not read a transcript, so I do not know whether it covers migrations or the build-time URL point. Platform dashboards change often, so treat button names as approximate. The Chethan TechVault video splits the three tiers across Vercel, Render and Supabase and is linked as the multi-provider version.
Where this fits
The app is now running at addresses like taskboard-api.onrender.com. Users need a real name and a padlock in the address bar, plus a separate staging copy to try things on first. That is the next lesson: environments, domains and TLS.
Check yourself
Why can't you change the API URL of a deployed Vite client by editing environment variables on the API host?
The client is static files. Vite replaces import.meta.env.VITE_* values with literal strings when it builds, so the URL is fixed in the bundle until you rebuild and redeploy the client.
Where do the database credentials live, and why not in the client build?
Only in the API host's runtime environment. Anything in the client bundle is visible to every visitor, so a secret there is public.
Why run migrations as a separate release step?
If the API runs them on boot, several instances can race, a failed migration leaves a half-started app, and you cannot see or roll back the schema change on its own.
What does a health check not prove?
That the app works for a user. It shows the process is up, but only a real request through the API to the database, and a real page load, prove the seams are connected.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.