2D top-down MMO RPG inspired by The Legend of Zelda: A Link to the Past.
npm install# Run both client and server
npm run dev
# Or separately
npm run dev:server # WebSocket server on :3002
npm run dev:client # Vite dev server on :5173# Build both client and server
npm run build
# Start production server
npm start # Server on port 3001 (serves client + WebSocket)This project uses Cloudflare Tunnel (cloudflared) to expose the production server to the internet.
Important: The production server runs on port 3001 (not 3002). Ensure your tunnel routes to the correct port.
cloudflared tunnel run wilhoCreate or update your ~/.cloudflared/config.yml:
tunnel: <your-tunnel-id>
credentials-file: /home/<user>/.cloudflared/<tunnel-id>.json
ingress:
- hostname: wilho.com.br
service: http://localhost:3001
- service: http_status:404Key Points:
- WebSocket connections automatically work through Cloudflare Tunnel
- No additional WebSocket configuration needed
- The tunnel forwards both HTTP and WebSocket traffic
- Ensure
servicepoints tohttp://localhost:3001(production port)
If users get stuck on "Connecting..." in production:
-
Check Browser Console - Open DevTools → Console tab
- Look for
[WebSocket]log messages - Connection errors will show the specific failure reason
- Look for
-
Check Network Tab - DevTools → Network → WS filter
- Look for
/wsWebSocket connection - Check if handshake is successful (Status 101)
- Failed connections show status codes and reasons
- Look for
-
Verify Tunnel is Running
# Check cloudflared process ps aux | grep cloudflared # Check tunnel logs cloudflared tunnel info wilho
-
Verify Server is Running
# Check server process ps aux | grep node # Check server is listening on port 3001 lsof -i :3001 # Or ss -tlnp | grep 3001
-
Test Local WebSocket Connection
# Using websocat (install: cargo install websocat) websocat ws://localhost:3001/ws # Or using wscat (install: npm i -g wscat) wscat -c ws://localhost:3001/ws
-
Check Server Logs
- Server logs include detailed WebSocket connection info:
- Client IP and origin
- Connection attempts
- Handshake details
- Connection/disconnection events
- Server logs include detailed WebSocket connection info:
-
Common Issues
- Wrong Port: Tunnel must route to port 3001, not 3002
- Server Not Running: Ensure
npm startis active - Firewall: Check if localhost:3001 is accessible
- SSL/TLS: Cloudflare handles SSL, server uses plain HTTP
NODE_ENV=production- Enables production mode (port 3001, serves static files)PORT=<custom_port>- Override default port (optional)DEV_START_PHASE=<phase>- Development only. Chooses the phase where new players spawn. Accepted formats: phase id (phase1,phase2, ... ) or number (1,2,3, ...). If the phase does not exist yet, server falls back tophase1.
Example (dev):
DEV_START_PHASE=2 npm run dev:server- Server (Node.js + ws): Authoritative simulation at 60Hz with separate 20Hz network snapshots
- Client (Vite + React + Phaser 3): Rendering, interpolation, prediction/reconciliation, and HUD
- Communication via MessagePack over WebSocket with snapshot delta replication
- Ataque especial do Gelehk
- Distance weapon (e.g. bow)
https://codeshack.io/images-sprite-sheet-generator/ https://www.tibiawiki.com.br/wiki/Outfitter?&o=39&an&q