Description
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-dev-utils/webpackHotDevClient.js#L61-L69
as shown in this file there is no way to config hostname and everything about this sockjs-node ajax request. is there any reason for it that there is no configuration for it ?
I`m working on a product which is not spa. uses cookie sessions and there is no authentication token obviously. so I was in need of hot reload to. I load my react app inside the main app and for the hot reload I did change the source code of webpackHotDevClient to what I want in order to make /sockjs-node/info ajax works.
without changing this config /sockjs-node/info hits http://app.dev/sockjs-node/info but I want it to hit on http://localhost:3000/sockjs-node/info.
var connection = new SockJS(
url.format({
protocol: "http",
hostname: "localhost",
port: "3000",
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node',
})
);
after this change things are working fines with hot reload on
Activity
luckydrq commentedon Sep 29, 2017
I have the same request. @hasangilak has found the clue.
If you need to serve documents that are dynamic rendered by a backend server, meaning you would have two servers: one is your backend server, the other is webDevServer. The two servers would occupy different ports. For example, your backend server listening at
7001
and webDevServer listening at3000
. Visit your page athttp://127.0.0.1:7001/index.html
, then subsequent requests for hot reload stuff will also followhttp://127.0.0.1:7001/
. It is obvious wrong and should behttp://127.0.0.1:3000/
.luckydrq commentedon Sep 29, 2017
react-dev-utils
may be an internal package forcreate-react-app
but i highly recommend to make it configurable. I believe that many people would use this project for reference and make their own configs, just like me :)sunfmin commentedon Oct 16, 2017
I have the same request. it is useful for dev when developing with another server :8080 with create react own :3000 one.
VasilyShelkov commentedon Dec 11, 2017
+1 as above ^^ SPA is on port 3000, non SPA app which includes it is on port :8000...
Making it configurable would be great 👍
dburrows commentedon Dec 11, 2017
I fixed this problem in this PR #1994 but it never got merged, there was a lot of discussion about a better solution but I was never entirely sure what the better solution was. Would love to get this fixed.
VasilyShelkov commentedon Dec 11, 2017
Agreed, I referenced another what looks to be related PR that never got merged either (#1588).
I've gone for the less than ideal temporary solution that has been suggested in this jist and run that as part of the
start
command https://gist.github.com/madebyherzblut/aef2377081aab39b9a780a418115d671. I know incredibly hacky, but achieves the desired effect and it is just fordev
viglucci commentedon Dec 22, 2017
Chiming in with my +1 for CRA to support more configuration for these types of scenarios. I know CRA takes a stance on convention > configuration, but I think providing more configuration for applications that are more than an SPA consuming an API would be a great improvement.
Much of the web is still running with server rendered content that relies on pre-loaded state, authentication, and routing handled server side, so seeing better support for those use cases would be great.
Thanks for reading.
gaearon commentedon Jan 8, 2018
For those use cases there are better tools like nwb. I encourage you to check them out. We can't possibly support all use cases, and intentionally focus on one: singe-page apps.
lgants commentedon Jan 9, 2018
I'm building a create-react-app server-side rendering boilerplate and this functionality would be fantastic. When the server's running on port 3000 and the client on port 3001 I can't take advantage of hot-reload. The code is available here: https://github.com/lgants/create-react-app-ssr.
dan-kez commentedon Feb 27, 2018
Also chiming with some additional support. We embed our CRA app in a separate site (different local port) by loading the bundle and it would be really helpful to have hotreloading.
maximandrews commentedon Jul 22, 2018
Did anyone tried to configure other way around proxying API Requests or may be I have some misconception of it?
stale commentedon Dec 8, 2018
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
stale commentedon Dec 13, 2018
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.