Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Allow webpack dev server to be externally accessed #124

Closed
chrischen opened this issue Apr 14, 2016 · 4 comments · Fixed by #376
Closed

Allow webpack dev server to be externally accessed #124

chrischen opened this issue Apr 14, 2016 · 4 comments · Fixed by #376

Comments

@chrischen
Copy link

Bind webpack-dev-server to 0.0.0.0 instead of localhost so that it can be accessed by machine IP.

I'm using another server (a VM in virtual network) as a frontend to React/node. Requests to to webpack-dev-server, including the request to /__webpack_hmr can't be proxied since it's bound to localhost and the VM is on a virtual network.

Specifically, I'm using nginx+php running in a VM as a front end that proxies server render requests to node, instead of accessing via localhost:8880.

See relevant issue here: webpack/webpack-dev-server#147

@christinebrass
Copy link
Contributor

Hi @chrischen, can you please test out the following branch and let me know if that contains the changes you'll need? If that works, I can see about integrating this via some sort of host option:

https://github.com/TrueCar/gluestick/tree/cybrass/hostname-changes

@chrischen
Copy link
Author

I tried to run this branch but I get

ERROR: During auto upgrade: Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/gluestick/new/src/config/.Dockerfile'

Also, re: proxying, it turns out that proxying the hmr connection doesn't seem to work for me either. The original issue is that despite wherever the javascript file is served from (in this case [hostname]:8888), the hmr updates are using a relative path, when they should also use the hostname that is specified.

Is that also addressed in this update?

Thanks!
Chris

On Apr 18, 2016, at 1:18 PM, Christine Brass notifications@github.com wrote:

Hi @chrischen https://github.com/chrischen, can you please test out the following branch and let me know if that contains the changes you'll need? If that works, I can see about integrating this via some sort of host option:

https://github.com/TrueCar/gluestick/tree/cybrass/hostname-changes https://github.com/TrueCar/gluestick/tree/cybrass/hostname-changes

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #124 (comment)

@chrischen
Copy link
Author

Ok I managed to get my install to run a custom gluestick and gluestick-shared.

Your changes work. But it turns out proxying the hmr endpoint isn't a good solution after all.

My main-bundle.js is set to use the endpoint localhost:

http://localhost:8888/assets/main-bundle.js

However, HMR updates do not use the specified host. They use a relative path, but should also use the specified host and port:

http://localhost:8888/__webpack_hmr

Instead it actually uses

http://local.test.domain/__webpack_hmr

Thanks!
Chris

On Apr 19, 2016, at 7:41 PM, Chris Chen chris.chen21@gmail.com wrote:

I tried to run this branch but I get

ERROR: During auto upgrade: Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/gluestick/new/src/config/.Dockerfile'

Also, re: proxying, it turns out that proxying the hmr connection doesn't seem to work for me either. The original issue is that despite wherever the javascript file is served from (in this case [hostname]:8888), the hmr updates are using a relative path, when they should also use the hostname that is specified.

Is that also addressed in this update?

Thanks!
Chris

On Apr 18, 2016, at 1:18 PM, Christine Brass <notifications@github.com mailto:notifications@github.com> wrote:

Hi @chrischen https://github.com/chrischen, can you please test out the following branch and let me know if that contains the changes you'll need? If that works, I can see about integrating this via some sort of host option:

https://github.com/TrueCar/gluestick/tree/cybrass/hostname-changes https://github.com/TrueCar/gluestick/tree/cybrass/hostname-changes

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #124 (comment)

@chrischen
Copy link
Author

The relevant change would be in
Lines 53-56 in gluestick https://github.com/TrueCar/gluestick/tree/0a9ecb21017a19f6e0bb8749380b69ad93d9711f/src https://github.com/TrueCar/gluestick/tree/0a9ecb21017a19f6e0bb8749380b69ad93d9711f/src/commands https://github.com/TrueCar/gluestick/tree/0a9ecb21017a19f6e0bb8749380b69ad93d9711f/src/commands/start-client.js

// Include hot middleware in development mode only
if (!isProduction) {
entry.unshift("webpack-hot-middleware/client");
}

Should allow customizing the hmr client options like here:
https://github.com/glenjamin/webpack-hot-middleware/blob/072b1475e45cc94df4cab99907c538283ce1fafa/example/webpack.config.js

This would remove the need to proxy for me.

On Apr 20, 2016, at 5:04 PM, Chris Chen chris.chen21@gmail.com wrote:

Ok I managed to get my install to run a custom gluestick and gluestick-shared.

Your changes work. But it turns out proxying the hmr endpoint isn't a good solution after all.

My main-bundle.js is set to use the endpoint localhost:

http://localhost:8888/assets/main-bundle.js http://localhost:8888/assets/main-bundle.js

However, HMR updates do not use the specified host. They use a relative path, but should also use the specified host and port:

http://localhost:8888/__webpack_hmr http://localhost:8888/__webpack_hmr

Instead it actually uses

http://local.test.domain/__webpack_hmr http://local.test.domain/__webpack_hmr

Thanks!
Chris

On Apr 19, 2016, at 7:41 PM, Chris Chen <chris.chen21@gmail.com mailto:chris.chen21@gmail.com> wrote:

I tried to run this branch but I get

ERROR: During auto upgrade: Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/gluestick/new/src/config/.Dockerfile'

Also, re: proxying, it turns out that proxying the hmr connection doesn't seem to work for me either. The original issue is that despite wherever the javascript file is served from (in this case [hostname]:8888), the hmr updates are using a relative path, when they should also use the hostname that is specified.

Is that also addressed in this update?

Thanks!
Chris

On Apr 18, 2016, at 1:18 PM, Christine Brass <notifications@github.com mailto:notifications@github.com> wrote:

Hi @chrischen https://github.com/chrischen, can you please test out the following branch and let me know if that contains the changes you'll need? If that works, I can see about integrating this via some sort of host option:

https://github.com/TrueCar/gluestick/tree/cybrass/hostname-changes https://github.com/TrueCar/gluestick/tree/cybrass/hostname-changes

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #124 (comment)

sethbattin added a commit that referenced this issue Dec 29, 2016
Address #124 and migrate server setting to the config file
@toddw toddw closed this as completed Jan 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants