-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Allow to override host/port for dev server #4468
Comments
There are Advanced Configuration Docs. |
@miraage I'm aware of
Therefore the bundle tries to connect to the wrong host/port combination because the dev server only listens on Is this now more easily understandable? |
Running into the exact same problem where I need to have SocketJS connect to something other than what is found in window.location. |
Running into this issue as well with a similar setup. If I just go into "node_modules" and edit webpackHotDevClient.js to fix the websocket port, then it works. You get basically the same thing as the auto-reloading page from "npm start" except servable from a backend app (it also means you can template the index.html with a backend framework). I think ideally the port (and maybe host) that I modified locally in webpackHotDevClient.js would be configurable. |
I would love to know why this is still an issue, as this isn't the only issue open for it. The logic thrown about in that other issue astounds me; exposing a defaulted port/host combo for this will in no way make weird or otherwise unwanted compromises for end-users. I've worked with enough people where ejecting is the norm, and this is consistently a pain point that nobody seems to want to press CRA about much because they've indicated it won't change. |
Just wanted to leave another vote for this feature. I'm integrating a CRA app into a .NET MVC app, so like others I am running the app from a different port. This wouldn't even have to be configurable, the port in webpackHotDevClient.js just needs to use the same port as the dev server, then it would continue to work for the 99% of users who don't care about this, and would work for those of us trying to integrate CRA apps into another app. |
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. |
We had the same issue as we would integrate a CRA app into another application through an iframe. I don't really understand why this rather easy fix can't be integrated. |
We are running into this issue as well. In our case, it is because we are running two separate projects on the same domain, and the one using this feature is on a subpath using a reverse proxy. ProjectA runs on http://mysite.local and ProjectB (which uses CRA) runs on http://mysite.local/sub, which is reverse proxied to localhost:9090. I would love to be able to tell webpackHotDevClient to use localhost:9090 as the hostname/port. |
This feature clearly has interest, and doesn't add complexity. What are the objections with implementing it?
@jylin I edited the port and that worked initially, but if I update my code the second request is back to localhost:3000. Did you have to edit anything other than these lines? |
Running into this issue as well. For reference webpack-dev-server's client has a nice solution to this: it uses the host/port in the url of the Could we do something similar here? |
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. |
Happy to send a PR to do something similar here, but I'd like the approach to be approved by a maintainer first. :) |
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. |
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. |
+1, Needed to have configuration for pot and host |
I've opened a PR here: #6724 but no feedback yet. I don't know how to get feedback / who should review it and nothing about this in the contribution guidelines. |
@n6g7 i'm just a fellow contributor. I'd recommend you to ask somebody from https://github.com/facebook/create-react-app/blob/master/.github/CODEOWNERS#L1 |
Is this a bug report?
No
This is related to #3814
We embedded a CRA-created app within another, larger app and would like to be able to adjust the host/port combination the webpack dev server/client use to connect to each other.
Our use case: the CRA-created app is a new frontend for a part of an existing application and requires authentication to access. Authentication is done via a session / cookie and therefore requests from the CRA-created app are required to send the session cookie alongside. This can be achieved in other ways than living on the same host/port combination as the "host" application but just serving it directly from the "host" application is certainly the easiest way when you don't have an existing SSO endpoint.
The problem: We run the dev server alongside the "host" application. We access
/static/js/bundle.js
viahttp://localhost:3000/static/js/bundle.js
in an HTML file served by the "host" application (e.g. on host/portexample.com:80
). When accessing that HTML file served by the host application, the JS is loaded successfully. It then tries to connect to the webpack dev server onhttp://example.com/sockjs-node/...
which is not working obviously because the dev server is running onlocalhost:3000
.We can successfully develop using that setup, just the dev server/hot reloading is not working.
I assume this would need one adjustement in
react-dev-scripts
to accept an env variable to connect to the dev server. Maybe we also need to adjust something based on an env variable in the dev webpack config.Is this feature out of scope for CRA or would you be open for a PR?
A minimal reproducible example to show this:
yarn start
/npm start
index.html
containing the following:serve
for that directory and access it.The text was updated successfully, but these errors were encountered: