Cloudflare Deploy (Free)

Replace Railway with Cloudflare Workers ($0). API deploy is manual — see local test workflow.

1. One-time: Cloudflare account

Sign up at dash.cloudflare.com (free).

2. One-time: Create KV + paste id in repo

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.

3. One-time: GitHub secrets (auto-deploy)

GitHub repo → SettingsSecrets and variablesActionsNew repository secret

Secret nameWhere to get it
CLOUDFLARE_API_TOKENCustom token — see permissions below
CLOUDFLARE_ACCOUNT_IDCloudflare 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 → ActionsDeploy Cloudflare APIRun 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.

4. Set API URL in game

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.

5. X login + cloud save (optional)

For real X login on any device, set Worker secrets in Cloudflare dashboard → Workers → monex-api → Settings → Variables:

In X Developer Portal → your app → OAuth 2.0:

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

6. GitHub Pages (free game site)

Repo → Settings → Pages → branch main → folder / (root)

Site: https://jericddd.github.io/MonEx/home.html

7. Shut down Railway (if still active)

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.

Test (PowerShell)

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.

Reset all progress + X log (test phase only)

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.

← Back to Home