0

I'm using Rails 5.1 with the Webpacker configuration that is now by default integrated in Rails. I've followed this article "Rails 5.1 loves Javascript" to get me on the right track.

So far so good. If run rails s on a shell and ./bin/webpack-dev-server --host 127.0.0.1 I can work on the application locally on my desktop.

The issue appears when I try to debug on iphone via my local wifi.

The phone can connect to the local machine via port 3000 and browse the entire application, but apparently it cannot find 127.0.0.1:8080 server and therefore the webpack bundle. Infact it throws this error:

Failed to load resources: cannot connect to server http://127.0.0.1:8080/packs/application.js

I've already tried running ./bin/webpack-dev-server --host 0.0.0.0 but I get the same error.

How do I need to set webpack-dev-server so Rails can load webpack resources?

I've also opened an issue on the official github of rails/webpacker.

1 Answer 1

0

My bad, everything works fine, I just didn't know I needed to connect to the local machine IP. Basically 127.0.0.1 and 0.0.0.0 aren't accessible outside the local machine. Therefore you need to explicitly declare which is the host when exposing Webpack dev server.

Adding the machine IP (which was 192.168.1.7) I've been able to connect:

./bin/webpack-dev-server --host 192.168.1.7

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .