Skip to main content

Testing on Localhost

Quick Testing Setup

You can test your game running on localhost directly in the Upside.win test environment without deploying. How it works:
  1. Run your game backend on http://localhost:3000 (or any port)
  2. Base64 encode your localhost URL
  3. Navigate to the test URL on upside.win

Step-by-Step

Step 1: Start your game backend
Step 2: Base64 encode your URL Using Node.js:
Using command line:
Online: Use any base64 encoder at https://www.base64encode.org/ Step 3: Test in Upside.win Visit the test URL:
Replace aHR0cDovL2xvY2FsaG9zdDozMDAw with your encoded URL.

Examples

Different localhost URLs:

Development Workflow

  1. Create game code - Write your React frontend and Cloudflare Hono backend
  2. Start locally - Run npm run dev on localhost
  3. Generate test URL - Base64 encode your localhost address
  4. Test on Upside - Visit https://upside.win/test/games/<BASE64>
  5. Get JWT & test - Game loads with real JWT for testing
  6. Iterate - Make changes locally and refresh the test URL
  7. Deploy - When ready, deploy backend and update game URL

Tips for Local Testing

  • Use same machine: Keep localhost running while testing
  • Check CORS: Ensure your backend allows requests from upside.win domains

Troubleshooting Local Testing

Problem: “Game not found” or 404
  • Solution: Verify localhost URL is correct and encoding is accurate
Problem: CORS errors
  • Solution: Your backend needs to accept requests from upside.win domain
Problem: JWT errors during testing
  • Solution: Make sure you’re using staging API key, not production
Problem: Network requests failing
  • Solution: Check that localhost is running and firewall allows requests

Complete Example: Coin Flip Game

Frontend (React)

Backend (Hono + Cloudflare Workers)

Troubleshooting

Common Issues

Problem: placeBet fails with “Insufficient balance”
  • Solution: Check player balance before placing bet, or increase bet amount display in UI
Problem: processPayout returns “session not found”
  • Solution: Verify sessionId matches bet response, check for typos
Problem: Duplicate game sessions or bets
  • Solution: Use same sessionId for retries, implement idempotency on your end
Problem: JWT expires during gameplay
  • Solution: Refresh token before game starts, handle token expiration gracefully
Problem: Game logic runs on client, leading to cheating
  • Solution: Move ALL game logic to backend, client only displays results