Skip to content

fix(examples): allow trycloudflare.com in Vite allowedHosts#8750

Merged
mvaligursky merged 2 commits into
mainfrom
mv-examples-trycloudflare-allowed-hosts
May 19, 2026
Merged

fix(examples): allow trycloudflare.com in Vite allowedHosts#8750
mvaligursky merged 2 commits into
mainfrom
mv-examples-trycloudflare-allowed-hosts

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

Allow the examples Vite dev and preview servers to accept requests when accessed through a Cloudflare quick tunnel (*.trycloudflare.com).

Changes:

  • Set server.allowedHosts and preview.allowedHosts to ['.trycloudflare.com'] in examples/vite.config.mjs

Without this, Vite 6 returns 403 on assets such as /@vite/client when the browser sends the tunnel hostname in the Host header (common for HTTPS headset / AVP testing via cloudflared).

Test plan

  • npm run dev in examples/, tunnel with cloudflared tunnel --url http://localhost:5555, open tunnel URL — examples shell loads without 403 on Vite assets
  • npm run build && npm run serve, same tunnel — preview works on tunnel URL
  • Local http://localhost:5555 still works unchanged

Vite 6 rejects tunnel Host headers with 403; allow *.trycloudflare.com for dev and preview so examples work over HTTPS tunnels (e.g. AVP testing).
@mvaligursky mvaligursky merged commit ab22692 into main May 19, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-examples-trycloudflare-allowed-hosts branch May 19, 2026 11:54
mvaligursky added a commit that referenced this pull request May 20, 2026
Adds optional HTTPS dev server for testing the examples browser on
phones, tablets, and XR headsets over LAN. The default `npm run develop`
flow is unchanged.

- New `develop:https` script — HTTPS variant of `develop`, reads certs
  from `examples/.cert/`. Fails fast if certs are missing.
- New `cert` script — generates local dev certs via mkcert for
  localhost, 127.0.0.1, ::1, and the machine's .local hostname. Extra
  SANs accepted as positional args: `npm run cert -- 10.0.0.42`.
- Vite `allowedHosts` switched from `.trycloudflare.com` (corp-blocked,
  #8750) to `['localhost', '.local']` for LAN device testing under
  Vite 6's host check.
- `examples/.cert/` added to .gitignore.
- README gains an "HTTPS dev for mobile / XR device testing" section
  with mkcert setup, per-device trust steps, dynamic LAN IPs, and
  troubleshooting.

Verified on Mac, Android, and Apple Vision Pro. Quest 3 path is
documented but not verified (requires Meta Developer Mode).

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
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.

1 participant