[Cloudflare deployment]

Pages + Worker for AXIS: frozen project pynescript-superchart, bindings, deploy order, EXTERNAL_BACKEND reality.

Cloudflare deployment

Abstract

Production AXIS on Cloudflare is a split deploy:

PieceRole
PagesStatic PWA (frontend/dist)
WorkerJSON API + WebSocket (frontend/worker)

Project id: pynescript-superchart — frozen infrastructure name (dashboard, wrangler, CI). Do not rename without a full binding/domain migration.

Evaluation truth: Worker /api/run proxies to EXTERNAL_BACKEND unless the gated Pyodide path is fully implemented and enabled. You still need a Python host (VPS Flask, container, etc.) for real Pine fidelity today.

Conceptual model

Deploy procedure

1. Provision bindings (once)

See Worker bindings:

  • KV API_KEYS, USAGE
  • D1 pynescript + schema
  • Optional R2, Durable Objects

2. Configure secrets / vars

Production checklist:

SettingProduction guidance
EXTERNAL_BACKENDPublic HTTPS URL of Flask/PYNE API
ALLOWED_ORIGINExact Pages origin (e.g. https://…pages.dev or custom)
ADMIN_TOKENSecret, strong
ALLOW_OPEN_KEYS"0" or unset
PYODIDE_IN_WORKER"disabled" until wheel pipeline ready

3. Deploy Worker

cd frontend/worker
npm install
npx wrangler deploy

4. Build & deploy Pages

cd frontend
bun install
bun run build
npx wrangler pages deploy dist --project-name=pynescript-superchart

Worker package also defines:

"deploy:pages": "wrangler pages deploy ../dist --project-name=pynescript-superchart"

5. Point the PWA

  • Engine endpoint: Worker URL (if path-mapped to /run) or Flask URL directly
  • Cloud storage endpoint: Worker origin
  • Ensure CORS allows Pages origin

Internals

PathRole
frontend/worker/wrangler.tomlWorker name + bindings
frontend/worker/README.mdOps narrative
frontend/worker/package.jsondeploy scripts
Makefile worker-deploy / pages-deployConvenience (verify Pages path)

Health check

curl -sS https://<worker>/health
# service: pynescript-axis-worker

Invariants & edge cases

  1. Pages ≠ Worker host — CORS required unless same-origin routing via custom domain routes.
  2. Localhost EXTERNAL_BACKEND is useless from the edge.
  3. DO migrations apply on deploy when uncommented.
  4. Observability enabled in wrangler for log tails (wrangler tail).

Failure modes

IssueFix
503 NO_BACKENDSet reachable EXTERNAL_BACKEND
CORS blockedALLOWED_ORIGIN mismatch
SPA HTML for wheelsPages must serve /vendor and /pyodide as static files
Stream NO_DOEnable SessionDO bindings

See also