Skip to content

Add QR code to server startup for easy mobile testing during local development#5

Open
jcorbettfrank wants to merge 1 commit intohytopiagg:mainfrom
jcorbettfrank:feat/qr-code-lan-access
Open

Add QR code to server startup for easy mobile testing during local development#5
jcorbettfrank wants to merge 1 commit intohytopiagg:mainfrom
jcorbettfrank:feat/qr-code-lan-access

Conversation

@jcorbettfrank
Copy link
Copy Markdown

@jcorbettfrank jcorbettfrank commented Mar 2, 2026

Summary

Adds a --tunnel flag to hytopia start that creates a Cloudflare quick tunnel and prints a QR code, making it easy to test your local dev server from a phone or tablet on any network. Also hardens the game server's CORS policy from a * wildcard to a strict origin allowlist.

What changed

  • Tunnel + QR codehytopia start --tunnel spawns a cloudflared quick tunnel, prints a scannable QR code and a mobile-friendly join URL. Tunnel failure is non-fatal; the server still starts with the local URL.
  • CORS hardening — Replaced wildcard CORS with an allowlist (hytopia.com, play.hytopia.com, *.play.hytopia.com, localhost). Adds proper OPTIONS preflight handling and access-control-allow-private-network for local dev.
  • CLI improvements — Rewrote argument parsing to correctly handle mixed positional args and flags. Added hytopia start --help.
  • Docs — Added "Remote Device Testing" section to the SDK README.

Configuration

  • --tunnel defaults to using cloudflared from PATH.
  • Set HYTOPIA_CLOUDFLARED_BIN=/path/to/cloudflared for a custom binary location.
  • Set HYTOPIA_CLOUDFLARED_NPX_PACKAGE=<name@version> to run via npx with a pinned version.

Testing

QR code printed on server startup with --tunnel:
image

Connected from iPhone:
Screenshot 2026-03-02 at 9 06 47 PM

Desktop still works:
image

@jcorbettfrank jcorbettfrank changed the title Add QR code LAN access to hytopia start Add QR code to server startup for easy mobile testing during local development Mar 3, 2026
jcorbettfrank added a commit to jcorbettfrank/hytopia-source that referenced this pull request Mar 3, 2026
- Remove dead 'h' from BOOLEAN_FLAGS (single-dash handled at top level)
- Fix --flag=value parsing to preserve data after second '=' sign
- Add SIGKILL fallback after 2s timeout for tunnel process cleanup
- Log tunnel startup errors when DEBUG env var is set
- Add comment explaining --no-tls-verify necessity (self-signed cert)
- Use fixed Content-Type for CORS allow-headers instead of reflecting
- Add comment explaining allow-private-network rationale

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jcorbettfrank jcorbettfrank force-pushed the feat/qr-code-lan-access branch from 9c367d4 to fdabe0d Compare March 3, 2026 02:50
@jcorbettfrank jcorbettfrank marked this pull request as ready for review March 3, 2026 02:54
@web3dev1337
Copy link
Copy Markdown

Noting that this PR has a similar use, so should be compared for best solution:

#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants