-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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: use relative HMR path #9734
Conversation
75f3fb6
to
7f38255
Compare
7f38255
to
a4ab956
Compare
Hey, could you list scenarios that you tested this and it works? We definitely need to verify any other scenarios to be as sure as possible that this won't break for some cases |
@pieh This should work in all situations where you host Gatsby on the root of the domain/IP. If you do access it via a Nginx/proxy on a sub URL you will need to use the I think the previous implementation made a wrong assumption that the by using the same IP address that the webpack was bound to be the same as the public-facing URL (in most cases this would be the same but not always). All this means is that the URL for For example, if your dev ENV sites inside a docker image or behind an HTTP proxy (for ssl/name based routing). is HMR used for anything other than the browser fetching it? |
a4ab956
to
d47f3d2
Compare
@drubin That is very logical and usually I would agree with you, but for some reason we had ip/port there as path even if docs for HMR doesn't use that in examples. I'm not sure if that is misconfiguration (using too specific path) or there was actual reason for that (one that I can't find in git history) |
@pieh Yes, you are right I tried quickly searching back in the history
I found it an older implementation
Seems like it was loading from another plugin and that plugin was passing it in as a query param. That doesn't seem to be the case? But of course without actually knowing why it was there in the first place its hard to figure out if it still passes that use case. |
I tried searching known issues and didn't find any so I think changing to relative is worth trying - if there will be issue reported we can revert this |
I don't remember why the code works as it does either. It's possible an earlier version of webpack/rhl needed things like this and then we didn't update. |
…lets just set / as basePath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @palerdot!
@palerdot thanks for the help fixing this. btw I am not actually on the Gatsby project, I just happened to have the same problem you did. :) |
@pieh @drubin @KyleAMathews Is info on |
@thebigredgeek was there a reason you picked an ENV variable for the publicpath instead of a command flag? Running |
Construct webpack hmr path relative to the request origin path to prevent url construction issues when accessing from local ip or any other ip that may be mapped to the dev server. This PR makes following changes to `getHmrPath()` method in `packages/gatsby/src/utils/webpack.config.js` - Always use the relative path `/` - Getting rid of manual url construction with protocol, hosts, ports etc as the relative path will automatically take care of this construction <!-- Q. Which branch should I use for my pull request? A. Use `master` branch (probably). Q. Which branch if my change is a bug fix for Gatsby v1? A. In this case, you should use the `v1` branch Q. Which branch if I'm still not sure? A. Use `master` branch. Ask in the PR if you're not sure and a Gatsby maintainer will be happy to help :) Note: We will only accept bug fixes for Gatsby v1. New features should be added to Gatsby v2. Learn more about contributing: https://www.gatsbyjs.org/docs/how-to-contribute/ -->
Construct webpack hmr path relative to the request origin path to prevent url construction issues when accessing from local ip or any other ip that may be mapped to the dev server.
This PR makes following changes to
getHmrPath()
method inpackages/gatsby/src/utils/webpack.config.js
/