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

Impossible to ignore proxy path prefix #887

Closed
maks-rafalko opened this issue Sep 28, 2015 · 7 comments
Closed

Impossible to ignore proxy path prefix #887

maks-rafalko opened this issue Sep 28, 2015 · 7 comments

Comments

@maks-rafalko
Copy link

Hi,

I need to proxy requests from /api to the root of other site: http://test.com:

/api/users -> http://test.com/users
/api/users/1 -> http://test.com/users/1

But all my requests lead to http://test.com/api/*
How to ignore /api prefix but not to ignore other path?
When I use ignorePath settings all my requests lead to http://test.com.

Config:

server.middleware = proxyMiddleware('/api', {target: 'http://test.com', proxyHost: 'test.com'});
@joeyespo
Copy link
Contributor

👍 Just ran into this too.

@borNfreee Find a suitable workaround since you posted this?

@sequoiar
Copy link

@borNfreee you may need use http-proxy with middleware like express.js or connect.js

@chimurai
Copy link
Contributor

chimurai commented Dec 2, 2015

@borNfreee's question has been answered in: chimurai/http-proxy-middleware#31 (comment)

@maks-rafalko
Copy link
Author

Thanks @chimurai You are right

@mik01aj
Copy link

mik01aj commented Jan 22, 2016

I have the same problem, but I can't use the @chimurai's solution because I don't use the middleware. I use the webpack dev server.

Would this be possible with just node-http-proxy options? Or do I need to request the feature from webpack guys?

@chimurai
Copy link
Contributor

@mik01aj
node-http-proxy doesn't offer path rewrite through options;
It's some sugar added by http-proxy-middleware.

Good news for you perhaps, HPM is now being used by webpack-dev-server.
webpack/webpack-dev-server#359

It is not push to npm yet, so you'll have to wait a bit...
pathRewrite option will be available there too (soon).

@mik01aj
Copy link

mik01aj commented Jan 22, 2016

That's some very good news, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants