Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configurable hostname for sockjs-node #3071

Closed
hasangilak opened this issue Sep 5, 2017 · 13 comments
Closed

configurable hostname for sockjs-node #3071

hasangilak opened this issue Sep 5, 2017 · 13 comments
Labels

Comments

@hasangilak
Copy link

hasangilak commented Sep 5, 2017

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

@luckydrq
Copy link

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 at 3000. Visit your page at http://127.0.0.1:7001/index.html, then subsequent requests for hot reload stuff will also follow http://127.0.0.1:7001/. It is obvious wrong and should be http://127.0.0.1:3000/.

@luckydrq
Copy link

react-dev-utils may be an internal package for create-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
Copy link

sunfmin commented 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
Copy link

+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
Copy link

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
Copy link

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 for dev

@viglucci
Copy link

viglucci commented 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
Copy link
Contributor

gaearon commented 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
Copy link

lgants commented 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
Copy link

dan-kez commented 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
Copy link

Did anyone tried to configure other way around proxying API Requests or may be I have some misconception of it?

@stale
Copy link

stale bot commented 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 stale bot added the stale label Dec 8, 2018
@stale
Copy link

stale bot commented 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.

@stale stale bot closed this as completed Dec 13, 2018
@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests