webpack-dev-server: V3.3.0 live reload broken when set hostname to `0.0.0.0:xxxx`

  • Operating System: MacOS

  • Node Version: v10.15.0

  • NPM Version: 6.4.`

  • webpack Version: 4.29.6

  • webpack-dev-server Version: 3.3.0

  • This is a bug

  • This is a modification request

Code

https://github.com/webpack/webpack-dev-server/blob/99e8db0f8cc441bb8f6acc60d786e33c38b8fc1d/client-src/default/index.js#L210

When start a node server like 0.0.0.0:8080, and load resources from 0.0.0.0:9000, Port was reset to self.location.port , which actually is 8080.

For Bugs; How can we reproduce the behavior?

  • Start webpack-dev-server and listen at e.g. 0.0.0.0:9000
  • Load resources from another local server like: 0.0.0.0:8080

Expected Behavior

Live reload should listen 0.0.0.0:9000

Actual Behavior

Live reload listen 0.0.0.0:8080

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 14
  • Comments: 39 (23 by maintainers)

Commits related to this issue

Most upvoted comments

my pr can fix your problem and you can also start your app by webpack-dev-server --port 8080 make it get the true port. because it use location.port if your urlParts.port is undefined but at this time ,you can’t add sockPath in your option, because here image if my pr is merge, you can set sockPort by webpack-dev-server --sockPort 8080

  1. Install dependencies and npm run dev

  2. Visit: http://127.0.0.1:8080/

  3. See network inspect, will get: image

Yes, release will be on this week

@pedrofurtado This fix will be fixed in the next version and the next version will be released in this week.

Oh, yes we don’t have sockHost now, i mean sockPath, if somebody needed in sockHost you can send a PR, it is easy

@hiroppy yep, some busy in this week, feel free to do this