Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HMR on .localhost domains #9435

Merged
merged 2 commits into from
Dec 13, 2023
Merged

Conversation

canac
Copy link
Contributor

@canac canac commented Dec 12, 2023

↪️ Pull Request

Fix HMR on .localhost domains (e.g. https://project.localhost).

Fixes #7490

💻 Examples

Before, it was trying to connect to the HMR websocket over the ws:// protocol, even though https://project.localhost is a secure domain. Now, it correctly uses the wss:// protocol.

🚨 Test instructions

Set up a project on https://project.localhost. An easy way is with caddy.

brew install caddy
printf "project.localhost {\n\treverse_proxy localhost:1234\n}\n" > $HOMEBREW_PREFIX/Caddyfile
brew services start caddy
parcel src/index.html # start a parcel project on port 1234
open https://project.localhost

Verify that the HMR websocket connection is made to wss://project.localhost/, not ws://project.localhost/

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@mischnic
Copy link
Member

This isn't specific to *.localhost though, right? It's really any domain containing "localhost" somewhere

@canac
Copy link
Contributor Author

canac commented Dec 12, 2023

This isn't specific to *.localhost though, right? It's really any domain containing "localhost" somewhere

That's correct. It's the same issue with hostnames like localhost.corp.com, 127.0.0.123, and 120.0.0.0. I just encountered it on .localhost domains.

@mischnic mischnic merged commit bd40574 into parcel-bundler:v2 Dec 13, 2023
14 of 16 checks passed
@canac canac deleted the hmr-localhost-tld branch December 13, 2023 14:12
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.

Use wss protocol for HMR on secure localhost domains
2 participants