ข้ามไปที่เนื้อหา

Production - Vercel

Deploy the web app and API on Vercel.

4 min read

Connect your agent today

Draft from chat, review in your calendar, and publish only what you approve.

เริ่มใช้งานฟรี

Deploy the backend (Express), web (SvelteKit), and optionally the CLI auth server (device flow for openquok auth:login) to Vercel.

Prerequisites

Backend on Vercel

Create a new Vercel project

and connect this repository.

Set Root Directory to backend

Set environment variables

Set Environment Variables in the Vercel project to match production (same names as backend/.env.production.local): NODE_ENV, Supabase keys, REDIS_* (prefix), FRONTEND_DOMAIN_URL, BACKEND_DOMAIN_URL, Stripe, OAuth, Sentry, email, etc.

Deploy

Deploy from the dashboard (push to the production branch) or from the repository root:

Deploy backend to Vercel (preview) — from the repo root; uploads the monorepo and installs workspace packages.

pnpm vercel:deploy:backend

Deploy backend to Vercel (production) — same command shape, production target.

pnpm vercel:deploy:backend:prod

After deploy, set BACKEND_DOMAIN_URL to your backend URL (for example https://your-api.vercel.app or a custom domain). Point Stripe webhooks and Google OAuth redirect URIs at that URL. Set the web app’s VITE_API_BASE_URL to the same backend base URL.

Example CLI prompts when running npx vercel link under backend/ (your paths and names may differ):

? Set up and deploy "~/Projects/.../openquok-monorepo/backend"? yes
? Which scope should contain your project? your-team
? Link to existing project? yes
? What's the name of your existing project? openquok-backend

Web on Vercel

Create a second Vercel project

and connect the same repository.

Set Root Directory to web

Set environment variables

Set Environment Variables to match production (same keys as web/.env.production.local): VITE_API_BASE_URL (your deployed backend), VITE_FRONTEND_DOMAIN_URL, VITE_PUBLIC_SUPABASE_* (prefix), Stripe and analytics keys as needed.

Deploy

Deploy web to Vercel (preview) — from the repo root; installs with pnpm at the monorepo root and builds the web workspace package.

pnpm vercel:deploy:web

Deploy web to Vercel (production) — same command shape, production target.

pnpm vercel:deploy:web:prod

CLI auth server on Vercel

The device-flow helper lives under agent/server. Create a third Vercel project with Root Directory set to agent/server.

cd agent/server
npx vercel link

agent/server/.vercel is gitignored; use VERCEL_ORG_ID and VERCEL_PROJECT_ID in CI if needed.

Environment variables

Maintain production values in agent/server/.env.production.local (gitignored), matching agent/server/.env.production.example. Sync into Vercel from the repository root:

pnpm vercel:env:sync:agent-server:prod

Required keys include DATABASE_URL, OPENQUOK_OAUTH_CLIENT_ID, OPENQUOK_OAUTH_CLIENT_SECRET, SERVER_URL (API origin, e.g. https://YOUR_CLI_AUTH_SERVER, no trailing slash), and BROWSER_ORIGIN (web origin for browser steps, e.g. https://web-production-ce4be0.up.railway.app).

Deploy web browser routes

The /cli/device/* pages live in the web project. Copy web/.env.production.example to web/.env.production.local, set CLI_AUTH_SERVER_URL to your auth server API origin, sync, and deploy:

pnpm vercel:env:sync:web:prod
pnpm vercel:deploy:web:prod

Deploy auth server API

pnpm vercel:deploy:agent-server
pnpm vercel:deploy:agent-server:prod

Or both projects:

pnpm vercel:deploy:cli-device-flow:prod

Register on your RedPanda OAuth app (RedPanda production reference):

https://web-production-ce4be0.up.railway.app/cli/device/callback

See Configuration - Agent → Scaling & Postgres for shared DATABASE_URL, SERVER_URL, and pooled connections on Vercel.

Custom domains (e.g. Route 53)

Add each domain in the Vercel project (Settings → Domains), create the DNS records Vercel shows (often CNAME to cname.vercel-dns.com or A records for apex), then set:

  • Backend: BACKEND_DOMAIN_URL, FRONTEND_DOMAIN_URL (and ensure CORS allows the frontend origin).
  • Web: VITE_API_BASE_URL, VITE_FRONTEND_DOMAIN_URL.
  • CLI auth server (if deployed): SERVER_URL for the API host; BROWSER_ORIGIN for browser URLs. Update the OAuth app callback when the web hostname changes (RedPanda production: https://web-production-ce4be0.up.railway.app/cli/device/callback).

Next steps

ค้นหาเอกสาร
ค้นหาหน้าเอกสาร
ศูนย์ช่วยเหลือ