Deploy Frontend to Cloudflare Pages

The frontend is built with React + Vite and produces static files (SPA). Cloudflare Pages is the recommended deployment platform.

Prerequisites

1. Create Pages Project

  1. Login to Cloudflare Dashboard → Workers & PagesCreate
  2. Select PagesConnect to Git
  3. Select your GitHub repository

2. Build Configuration

Since the project uses a monorepo structure, pay attention to the configuration:

SettingValue
Build commandnpm ci && npm run build --workspace=console
Output directoryconsole/dist
Root directory/ (keep default)
Node.js version22

Set Node.js version: Add NODE_VERSION = 22 in Environment variables.

3. Environment Variables

In Cloudflare Pages → SettingsEnvironment variables, add the required frontend variables:

PUBLIC_BACK_END=https://api.yourdomain.com
PUBLIC_CONSOLE_URL=https://console.yourdomain.com
...

Frontend environment variables must be prefixed with PUBLIC_ to be accessible in code. They share the same .env file with the backend.

4. Custom Domain

  1. Pages project → Custom domainsSet up a custom domain
  2. Enter your domain, e.g. console.yourdomain.com
  3. Cloudflare will automatically add DNS records and provision SSL

Deployment Triggers

5. SPA Routing (Pages deployment only)

If deploying via Pages (not Workers), create a _redirects file in console/public/:

/*  /index.html  200

If deploying via Workers (wrangler deploy), wrangler.jsonc already includes not_found_handling: "single-page-application". This file is not needed.

Notes