Replace Railway with Cloudflare Workers ($0). API deploy is manual — see local test workflow.
Sign up at dash.cloudflare.com (free).
On your PC (PowerShell), after npm install -g wrangler and wrangler login:
cd MonEx\cloudflare\monex-api npm install npx wrangler kv namespace create MONEX_KV
Copy the id into cloudflare/monex-api/wrangler.toml (replace REPLACE_WITH_KV_ID), commit and push to main.
You only do this once. KV is your database for catches, saves, and sessions.
GitHub repo → Settings → Secrets and variables → Actions → New repository secret
| Secret name | Where to get it |
|---|---|
CLOUDFLARE_API_TOKEN | Custom token — see permissions below |
CLOUDFLARE_ACCOUNT_ID | Cloudflare dashboard → Workers & Pages → right sidebar Account ID |
Create a Custom Token with these permissions (all required):
Account Resources: Include → your account. Zone Resources: Include → All zones.
After secrets are set, deploy manually: GitHub → Actions → Deploy Cloudflare API → Run workflow.
API does not auto-deploy on every push — batch changes, then deploy once when you are ready.
Check runs: GitHub → Actions tab → Deploy Cloudflare API.
Edit js/monex-config.js on GitHub and push to main:
window.MONEX_API = "https://monex-api.YOURNAME.workers.dev";
After the first auto-deploy, copy your real workers.dev URL from GitHub Actions or Cloudflare dashboard.
For real X login on any device, set Worker secrets in Cloudflare dashboard → Workers → monex-api → Settings → Variables:
X_CLIENT_IDX_CLIENT_SECRETIn X Developer Portal → your app → OAuth 2.0:
https://monex-api.YOURNAME.workers.dev/api/auth/callbackSet in wrangler.toml vars and push:
FRONTEND_ORIGIN = "https://jericddd.github.io/MonEx"
Until OAuth is set up, dev login works: enter your @handle on the login button.
Repo → Settings → Pages → branch main → folder / (root)
Site: https://jericddd.github.io/MonEx/home.html
If you still have a MonEx service on railway.app, delete it there to save ~$5/month. Railway config files have been removed from this repo.
Invoke-RestMethod -Uri "https://monex-api.YOURNAME.workers.dev/api/simulate-mention" -Method POST -ContentType "application/json" -Body '{"text":"@monexmonad catch 10 monanimals","username":"jeric"}'
Home → Login with X (or dev @handle) → Play. Progress saves to Cloudflare automatically.
Test catch: simulate mention, then open game — mons auto-sync to Party/Box.
Not for go-live. Before launch: set ENABLE_ADMIN_RESET=0 in wrangler.toml, delete ADMIN_RESET_SECRET, and push — reset becomes permanently off.
During testing, set Worker secret ADMIN_RESET_SECRET and keep ENABLE_ADMIN_RESET = "1" in wrangler.toml.
Invoke-RestMethod -Uri "https://monex-api.0xjericd.workers.dev/api/admin/reset" -Method POST -ContentType "application/json" -Headers @{ "X-Admin-Secret" = "YOUR_SECRET" }
Clears: X wild log, catches, cloud saves, sessions. You log in again after.