-
-
Notifications
You must be signed in to change notification settings - Fork 27k
WebSocket proxy #6497
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
Comments
@jamescostian if you follow the instructions for "Configure the Proxy Manually" here: https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development#configuring-the-proxy-manually then in the instructions it tells you to create a file src/setupProxy.js you can put in the following const proxy = require('http-proxy-middleware');
const URI = process.env.REVERSE_PROXY_URI || 'http://localhost:8000'
module.exports = function(app) {
const apiProxy = proxy('/graphql', {target:URI});
const wsProxy = proxy('/graphql', {ws:true, target:URI});
app.use(apiProxy);
app.use(wsProxy);
}; for production you can use this, some old code I had from 2015 helped me figure this out
|
Hi, I have tried the above, while I still have the following problem: The front-end is making http request to the port itself, instead of the backend port. Setting: What I put in the setupProxy.js:
The way I am doing request:
Error message:
How can I force it to use my backend port for fetching? |
You already have forced it to use your backend port for fetching, and your backend is sending the 404. For example, try |
I have tested sending GET request to backend According to the error message So I think it looks like |
But that message is coming from the frontend, right? The frontend is talking to Here's another example. Change your frontend code to EDIT: one idea I have is it could be an INSANELY specific bug (e.g. the backend is 404ing because your frontend user has certain cookies, or because you have a certain Referrer header, etc.). Try going to the network tab on Chrome after your frontend makes the request to |
Thank you very much for your detailed explanation! I have understand now and the problem has been solved! It's because that the request path is not correct. Just double check if the proxy path is consistent with your backend path, should be fine! |
Ok |
There's a new PR to fix this issue in #6515. |
There is a bug report in #5280 that documents the regression, and there's a potential fix in #5841 that was closed by the stale bot. The bot mentioned "If you have a question or comment, please open a new issue" and I have a question: can someone please merge that fix?
The text was updated successfully, but these errors were encountered: