feat(hub-client): opt-in HTTPS dev server for mobile/network testing#276
Merged
Conversation
Add @vitejs/plugin-basic-ssl and wire it behind VITE_HTTPS=1 so developers can serve the dev server over HTTPS when testing on phones or other devices on the local network. Without HTTPS the browser treats the IP-address origin as insecure and blocks crypto APIs, producing a blank white page. Usage: VITE_HTTPS=1 npm run dev:fresh -- --host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this, I was able to test, in Firefox on an Android tablet over my local network:
There were some automerge timing glitches but it all worked!
Summary
@vitejs/plugin-basic-sslas a dev dependencyVITE_HTTPS=1is set, so the default dev workflow is unchangedhub-client/README.mdunder a new "Testing on Mobile / Other Devices" sectionMotivation
When accessing the Vite dev server by IP address (e.g. from a phone on the same WiFi), the browser treats
http://192.168.x.xas an insecure context and refuses to runcrypto.randomUUID()andcrypto.subtle— APIs the app calls at startup. The result is a blank white page with no visible error.Serving over HTTPS fixes this. The self-signed cert triggers a one-time browser warning, which is acceptable for local dev.
Usage
```bash
VITE_HTTPS=1 npm run dev:fresh -- --host
```
Vite will print the
https://192.168.x.x:5173/network URL to open on the device. Accept the self-signed cert warning on first visit.Test plan
npm run dev:fresh(no env var) still starts on HTTP — no regressionVITE_HTTPS=1 npm run dev:fresh -- --hostserves HTTPS and is reachable from a device on the same network