question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No way to force webpack-dev-server client to use window.location

See original GitHub issue
  • Operating System: macOS 10.15.3
  • Node Version: v12.16.0
  • NPM Version: 6.13.4
  • webpack Version: 4.41.6
  • webpack-dev-server Version: 3.11.0
  • Browser: Chrome 81
  • This is a bug
  • This is a modification request

Expected Behavior

There would be some configuration that would let me force webpack-dev-server’s hot client to use window.location.

Actual Behavior

No configuration will cause webpack-dev-server’s hot client to not use __resourceQuery, which in my case is always "?http://localhost:8080". As far as I can tell, I can’t get this behavior with the current configuration options.

For Features; What is the motivation and/or use-case for the feature?

I’m working on a cloud platform that provides dev environments, and it let’s you proxy requests to localhost via a domain. Out of the box, webpack-dev-server doesn’t work since it tries to hit localhost:8080/sockjs-node. We’ve been working around this by setting public to an environment variable, but the annoying thing is that everyone gets a different domain. It’d be ideal if we could just set a flag on the devServer config that told it to always use window.location so each user wouldn’t have to configure an environment variable.

It’s worth noting that create-react-app doesn’t encounter this because of their custom hot client, which has much simpler logic: https://github.com/facebook/create-react-app/blob/master/packages/react-dev-utils/webpackHotDevClient.js#L59-L69

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
LannyBosecommented, Jun 3, 2020

For folks Googling their way here looking for answers, this hack proposed a few years ago still works (from #1240):

devServer: {
  public: '0.0.0.0:0',
  host: '0.0.0.0',
  disableHostCheck: true
},

…to get the client to fallback to window.location.

0reactions
alexander-akaitcommented, Jun 3, 2020

@lperiodbose thanks, let’s close in favor https://github.com/webpack/webpack-dev-server/issues/1240, try to find time on it for v4

Read more comments on GitHub >

github_iconTop Results From Across the Web

DevServer - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Webpack-dev-server compiles files but does not refresh or ...
I'm trying to use webpack-dev ...
Read more >
Why webpack-dev-server Live-Reload Is Not Working - Medium
Firstly, why would anybody use webpack-dev-server? ... This means that any code change, appears automagically and instantly on the browser.
Read more >
Webpacker - Ruby on Rails Guides
This guide will show you how to install and use Webpacker to package JavaScript, CSS, and other assets for the client-side of your...
Read more >
location.reload() - Web APIs | MDN
reload() , to tell Firefox to bypass its cache and force-reload the current document. However, in all other browsers, any parameter you specify ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found