-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
devServer proxy not working #793
Comments
Have you tried |
@steve-taylor I have indeed. |
I tried to reproduce this, but it does work for me. What's interesting though is that the error message I get in the browser is wrong. It says "Error occured while trying to proxy to: localhost:8080/api/users" even though the proxy is set to |
I wonder if there's a way to plug in a reverse proxy that actually works, rather than being handcuffed to http-proxy-middleware. |
Yeah not sure.. Here's my whole config in case there's something else afoot. Maybe I've got something funky in the
|
@steve-taylor what specific issues are you having? I would suggest creating github issues on http-proxy-middleware for those. The author of http-proxy-middleware is very responsive and helpful. |
@gjunkie can you make a repository with a minimal version of the backend you have on port 8000? That's the only way to be able to debug this further down. |
@SpaceK33z I decided to shift over to use Hapijs' cors feature for my needs, however this is the repo I was attempting to proxy in. Beyond removing the proxy option, there haven't been other changes, in case this helps. |
I have the same problem as @gjunkie. Starting from v1.15.0 the http-proxy-middleware is installed as dependency and a ECONNRESET error is thrown each time I try to make a request to the backend. Apparently, it is only happening in OS X environment because my colleagues at work are using Ubuntu and they can't reproduce this problem. |
I could reproduce this bug on OS X. In Windows, it is working just fine. |
I couldn't get devServer proxy to work either (OS X 10).
Reference: https://codeforgeek.com/2015/12/reverse-proxy-using-expressjs/ |
How to set proxy buffer, i want to upload some files to backend |
Having the same issue here, also OSX |
same issue on OSX |
Same issue on OSX as well. |
This configuration is working for me on OSX (I sweated blood to make it work). I have the GNU Coreutils installed, by the way (don't know if has something to do). , proxy: [
{
path: /^\/styleguide(?!\/core-css\/build)/
, target: 'http://localhost:8000'
, bypass: function(req, res, _options) {
return req.url.replace('styleguide', styleguideRoothPath + '/build');
}
}
, {
path: "**",
target: "http://localhost:3000",
secure: false,
bypass: function(req, res, options) {
if(req.url === '' || req.url === '/') {
res.statusCode = 302;
res.setHeader('Location', '/a/');
return '/a/';
}
var frontend = new RegExp("^\/$^|\/a\/index\.html|^\/a\/|^\/a$|^\/styleguide");
if (frontend.test(req.url)) return req.url;
}
}
] |
Same issue on OSX. |
replace localhost with [::1]. this works for me:
one wildcard, or double, with 'secure' or 'changeOrigin' - doesnt matter. [::1] is the game changer. |
Meet the same issue on mac, any progress here? |
We've got a few workarounds posted for folks running into the issue. It seems that this might be slightly edge casey, however. If anyone would like to put together a Pull Request, we'd happily review it and revisit this issue. |
In my case, I had to rewrite the path:
Hope this can help. |
I'm still having issues with this on Mac OSX and have tried everything above. Related: #458 (comment) EDIT: I think I was expecting the opposite behavior for some weird reason. By proxying the web server through the dev server, I should still be using the dev server, not the actual server while developing. |
It's working for me now. Turned out I was just missing adding |
Make sure that your request url and port matches that which your webpack-dev-server is running on. So, if your api is located at http://localhost:5000, and your dev server is running on http://localhost:8080, make sure all of your requests are to http://localhost:8080. Its best to make your requests to localhost:8080/api (to avoid conflict with app routes) and use the path rewrite to remove the /api. Example:
Webpack dev server running on: http://localhost:8080 In your app, make the request to: http://localhost:8080/api/items. This should work. It seems to me that all of the above issues stem from making the request to the API url and port rather than the webpack dev server url and port and using the proxy and path rewrite to direct the request to the API. |
@jrweinb, thanks for your clear explanation. I was trying to GET the API port like you had described, but it is still not working. In the console I have two errors,
The second error points to line 4 here, there is no '<' as described
|
@withintheruins14 - (I deleted a previous reply as it was wrong). It looks like your API is not working. The 404 html is getting parsed in |
** SOLVED ** @jrweinb, thanks for sticking with me - I am still trying to get this sorted. Yes, my request was 404ing but that is because the dev-server proxy isn't working. To me, my files appear in proper order, here they are: actions/prospect.js
webpack.config.js
package.json
Thanks! |
The above was solved. My problem was on the server and not within my webpack.config.js. Our Flask server prevents all requests from different servers when a server name is specified. To fix this, we simply left the server name unspecified in config.py. Thanks for your help @jrweinb |
@jellyfish-tom your solution did it for me with Mac OSX 10
|
@italoborges You saved my life:)
|
I ran into the same issue and found
in webpack.dev.conf.js . BTW. This is my config for proxytable (now working again):
|
I am also facing this issue |
I'm having a similar problem with the proxy - but same here, nothin is workin. I have a repo I could share: https://github.com/writesandy/SSMRB |
@jellyfish-tom thanks Now mine is working, here's my config: devServer: { |
For Webpack 4 and OSX10, I had to add changeOrigin property to make it work.
|
For us setting the header
|
Our UX guy has also been suffering the |
If this is helpful for any one browsing the topic, this setup works for me on
I'm using osX and these dependencies (if you find it relevant to your setup):
I also noticed that using the |
@jrweinb thank you! it works! |
proxy to http://some.localhost:8888 not working! Just ENOTFOUND |
This should work:
|
I have tried, but getting this issue |
getting error "http://localhost:9898/api/v3/sign-in 404 (Not Found)" |
In my case it doesn't work when a file that should be proxied exists. |
Switching the hostname from 'localhost' to the ipv6 '[::1]' fixes the dev server proxy webpack/webpack-dev-server#793 (comment) Signed-off-by: Tim Etchells <tetchell@redhat.com>
Switching the hostname from 'localhost' to the ipv6 '[::1]' fixes the dev server proxy webpack/webpack-dev-server#793 (comment) Signed-off-by: Tim Etchells <tetchell@redhat.com>
Solution for this stack:
|
The issue is 4+ years old. Though it is closed I am wondering why no-one references a documentation where it is (officially) described how it all works. By the way, I do have the same problem as @gjunkie stated in the first post. I see variants of webpack usage, path-rewrite, /api/** usage, secure: false, pathRewrite...you name you'll find it but without proper documentation reference. Well, I made it run on other projects so far, but it is sucky that it always consumes so much time to get it working... |
Thank you for explaining the problem clearly. Change the interface to be accessed to the IP and port of the dev server, make sure it belongs to the same domain, and then access the correct server IP and port through proxy. If you understand the process, you'll know how to configure it, right |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
devServer proxy doesn't proxy.
If the current behavior is a bug, please provide the steps to reproduce.
Client server running at
localhost:8080
and API server running atlocalhost:8000
. I've tried several variations of what to proxy (api/*
,/api/**
,api/**
, etc). Use the following proxy settings:What is the expected behavior?
Hitting
/api/path
should be proxied tohttp://localhost:8000/api/path
but is instead hittinghttp://localhost:8080/api/path
.Please mention your webpack and Operating System version.
The text was updated successfully, but these errors were encountered: