Static Hosting + Standalone API
Static Hosting + Standalone API
For global CDN performance, you can deploy the static frontend to Cloudflare Pages or Vercel while hosting the Node API backend on a separate server.
1. Frontend Pages Deployment
- Build the frontend:
Terminal window pnpm run build - Publish the
dist/directory to Cloudflare Pages or Vercel.
2. Standalone Backend Setup
On your server (e.g. Linux VPS):
pnpm run build:apipnpm run start:apiCORS Configuration (ALLOWED_ORIGINS)
Because frontend and backend reside on different domains, set ALLOWED_ORIGINS in your backend environment:
PORT=3001ALLOWED_ORIGINS=https://your-app.pages.devGEMINI_API_KEY=AIzaSyYourServerManagedKey3. Client Connection
In the deployed frontend, navigate to Settings -> Providers & API:
- Enable “Custom API Config / Proxy”.
- Set the proxy endpoint:
https://api.yourdomain.com/api/gemini.