Skip to content

configurable hostname for sockjs-node #3071

Closed
@hasangilak

Description

@hasangilak

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

luckydrq commented on Sep 29, 2017

@luckydrq

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

luckydrq commented on Sep 29, 2017

@luckydrq

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

sunfmin commented on Oct 16, 2017

@sunfmin

I have the same request. it is useful for dev when developing with another server :8080 with create react own :3000 one.

VasilyShelkov

VasilyShelkov commented on Dec 11, 2017

@VasilyShelkov

+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

dburrows commented on Dec 11, 2017

@dburrows

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

VasilyShelkov commented on Dec 11, 2017

@VasilyShelkov

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

viglucci commented on Dec 22, 2017

@viglucci

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

gaearon commented on Jan 8, 2018

@gaearon
Contributor

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

lgants commented on Jan 9, 2018

@lgants

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

dan-kez commented on Feb 27, 2018

@dan-kez

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

maximandrews commented on Jul 22, 2018

@maximandrews

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

stale

stale commented on Dec 8, 2018

@stale

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 commented on Dec 13, 2018

@stale

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.

locked and limited conversation to collaborators on Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sunfmin@dburrows@Timer@gaearon@luckydrq

        Issue actions

          configurable hostname for sockjs-node · Issue #3071 · facebook/create-react-app