Skip to content

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

  1. Build the frontend:
    Terminal window
    pnpm run build
  2. Publish the dist/ directory to Cloudflare Pages or Vercel.

2. Standalone Backend Setup

On your server (e.g. Linux VPS):

Terminal window
pnpm run build:api
pnpm run start:api

CORS Configuration (ALLOWED_ORIGINS)

Because frontend and backend reside on different domains, set ALLOWED_ORIGINS in your backend environment:

Terminal window
PORT=3001
ALLOWED_ORIGINS=https://your-app.pages.dev
GEMINI_API_KEY=AIzaSyYourServerManagedKey

3. 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.