Before deploying
A checklist of security and operational choices to review before production.
This project is a starting point; review the security and operational choices for your application before production use.
- Set production environment variables through your hosting provider's secret manager. Use unique, rotated credentials and TLS for external connections.
- Check them with
pnpm check:envin the production environment: it lists every variable your modules need that is unset, points atlocalhost, or isn't an absolute URL. Vercel and Netlify builds run it first and stop on a problem. With a separate API, it checks the API's variables, so review the frontend's variables yourself. - Supabase Auth: set the app URL variable to the deployed origin and add its
/auth/callbackURL to Supabase's allowed redirect URLs. On React + Vite, add the frontend's/loginand/reset-passwordURLs instead. - Auth: make authenticated server routes call
getCurrentUser()orrequireUser()from@/server/auth(the latter throws a 401AppError), and protect pages withgetPageUser, which redirects signed-out visitors to/login. Do not treat cookie contents alone as proof of identity. With a separate API, check the user in every API route that needs one, as/api/sessiondoes; see Authentication. - React + Vite: build the frontend with your provider's
VITE_*values, since Vite compiles them in, and keep secrets out of them: everything in aVITE_*variable reaches the browser. SetFRONTEND_URLon the API to the frontend's origin, which its CORS allows. Unless the browser calls the API directly (VITE_API_URL), keep the API private, reached through the frontend's/api. - Storage: authorize storage access and validate upload size, content type, and object ownership in the route before using the storage adapter.
- Cache: configure Redis for rate limiting when you deploy more than one instance; the in-memory fallback does not share counts between instances. With
--cache memory, deploy one instance or switch to a shared store before scaling out. - Client addresses: tell the server where each client's address is for your host, with
CLIENT_IP_HEADERorTRUSTED_PROXY_HOPS, so rate limits count each client on its own. See below. - Mobile app: set its own id and
WEB_URLbefore the first build, and theAPP_*versions on the API when you release a version, with each store's link (APP_UPDATE_URL_IOS,APP_UPDATE_URL_ANDROID). Change the API contract only in ways installed apps survive. See The mobile app. - Native app: set its own id in
apps/mobile/app.config.tsbefore the first release build, andEXPO_PUBLIC_API_URLto the publichttps://address it calls. Raise itsversionwith each release, and set theAPP_*versions on the API as for the mobile app. See The native app. - Without a website: make every API route that acts for a user check the request's user first, as the account routes do, and answer 401 without one; don't trust a user id a client sends. With Supabase Auth, add the native app's address scheme to Supabase's Redirect URLs. See Without a website.
- Configure and verify a restrictive Content Security Policy for the scripts and asset origins used by your deployment. A generic policy is not included because it can break framework tooling and project-specific assets.
- Review database migration and backup procedures, provider access policies, and application-specific error handling.
Client addresses
Rate limits count requests per client address, so the server must know which address a request comes from (Starter v0.27.0 or newer). That depends on what sits in front of it, which two settings describe:
CLIENT_IP_HEADER: a header your host sets to the client's address, replacing any copy the client sends. The address is that header's value.TRUSTED_PROXY_HOPS: how many reverse proxies you run in front of the server that append toX-Forwarded-For, such as Caddy, nginx, Traefik, or a load balancer. The address is the entry that many places from the end, the one your outermost proxy added; entries before it are whatever the client sent, so they never count.
CLIENT_IP_HEADER wins when both are set. Without either, or when a request lacks what they name, the address is the connection's own, which is right for a server that clients reach directly. A value that can't be right stops the server at startup, and pnpm check:env reports it.
| Where the app runs | Setting |
|---|---|
| Railway | CLIENT_IP_HEADER=x-real-ip |
| Render | CLIENT_IP_HEADER=cf-connecting-ip (render.yaml) |
| Fly.io | CLIENT_IP_HEADER=fly-client-ip (fly.toml) |
| Vercel | CLIENT_IP_HEADER=x-real-ip |
| Netlify | CLIENT_IP_HEADER=x-nf-client-connection-ip |
| Behind proxies you run (Caddy, nginx) | TRUSTED_PROXY_HOPS=1, or the number of proxies |
| Reached by clients directly | Neither |
pnpm clubedge deploy sets the one for its platform (CLI 0.42.0 or newer), and TRUSTED_PROXY_HOPS=1 behind Caddy with Docker Compose. Vercel and Netlify take runtime variables only from the project's settings, not from vercel.json or netlify.toml, so set CLIENT_IP_HEADER there with the others when you deploy by hand.
Next.js gives the app no connection address, so without either setting the address is the last X-Forwarded-For entry, the one the proxy nearest the app added: right on Vercel, which replaces the header with the client's address, and behind one proxy you run. Set your host's setting from the table anyway, since some hosts add more than one entry.
With a frontend and its API, the frontend's server finds the address with its own settings and sends it to the API as the only X-Forwarded-For entry, dropping any address header the client sent. An API that only the frontend's server reaches, over a private network as in docker-compose.yml, sets TRUSTED_PROXY_HOPS=1.
Without a website, clients reach the API itself, so the API takes the setting for where it runs, from the table above. pnpm clubedge deploy sets it: TRUSTED_PROXY_HOPS=1 with Docker Compose, behind Caddy, and CLIENT_IP_HEADER=x-real-ip on Railway.
Run the checks
pnpm clubedge doctor
pnpm lint
pnpm typecheck
pnpm test
pnpm format:check
pnpm buildBrowser checks use Playwright. Install Chromium once, then run them:
pnpm exec playwright install chromium
pnpm test:e2eThe Playwright configuration starts the local app with a placeholder database URL; browser scenarios should not require real provider credentials.
How is this guide?