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.

Working together with a backend on a different port?

See original GitHub issue

Not sure if I’m messing up something with the configuration, or my usecase is not suitable for react-hot-loader. So I have an application that runs on python (Flask), on localhost:5000. I followed the guide on http://gaearon.github.io/react-hot-loader/getstarted/, how to configure react-hot-loader for automatic reloading, and it almost works. The js files get bundled up, they are being watched for changes, and the browser gets notified about changes, however it sends an ajax request to an incorrect url:

http://127.0.0.1:5000/6495ade23756374f56fd.hot-update.json

Note the port number, this will be handled by Flask, which will result in a 404.

So to clarify:

My python backend is running on localhost:5000 Webpack server is running on 3000 (as per the tutorial) I’m loading the JS bundle with:

<script type="text/javascript" src="http://localhost:3000/bundle.js"></script>

When I initially open my application in the browser (by going to http://localhost:5000), I see this in the firebug console:

GET http://0.0.0.0:3000/socket.io/1/?t=1425134048889 200 OK         1ms bundle.js (line 2381)
[HMR] Waiting for update signal from WDS... bundle.js (line 706)
[WDS] Hot Module Replacement enabled.

(which is good!)

But when I change a file, this gets logged in the firebug console:

[WDS] App updated. Recompiling... bundle.js (line 572)
[WDS] App hot update... bundle.js (line 614)
[HMR] Checking for updates on the server... bundle.js (line 701)
GET http://127.0.0.1:5000/f450e336c3b076f73ab0.hot-update.json 404 NOT FOUND        2ms bundle.js (line 26)
"NetworkError: 404 NOT FOUND - http://127.0.0.1:5000/f450e336c3b076f73ab0.hot-update.json"
f450e33...te.json
[HMR] Cannot find update. Need to do a full reload! bundle.js (line 644)
[HMR] (Probably because of restarting the webpack-dev-server)

For some reason it sent a request to :5000 for the hot-update.json, instead of :3000.

Did I miss something when configuring webpack? Or do I have to proxy requests to the webpack server from my application server?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:16
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
AllenZengcommented, May 12, 2016

in this issues https://github.com/gaearon/react-hot-loader/issues/194 @seburgi suggest adding " publicPath: ‘/’ " to output section, so it looks like this:

output: {
    path: Path.join(__dirname, 'build'),
    filename: 'bundle.js',
    publicPath: '/',
},

That help me fixed the problem.

4reactions
brentatkinscommented, Nov 9, 2016

@AlexLeung I have it set to http://localhost:3000/ and it works for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Different ports for frontend and backend. How to make a ...
A better approach in my opinion is to handle this in your infrastructure by proxying the backend in your frontend application. With proxying...
Read more >
Running Frontend and Backend Development Servers Together
You'd want to somehow combine both servers, so they can interact with each other. But each can only run on its own port....
Read more >
Make a request between frontend and backend locally ...
step 1) Run the frontend at say port 8001. step 2) Run the backend at say port 8002.
Read more >
Manage port forwarding for backend pool with Azure Load ...
Port forwarding lets you connect to specific virtual machines by using the Load Balancer frontend IP address and port number. Load Balancer, ...
Read more >
Connecting Front-End and Back-End Applications
Create a back-end and front-end application in two separate repositories and allow them to talk to each other - even on production.
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