-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Request uri rewrite in proxy settings? #344
Comments
Use the rewrite callback:
Or ES2015:
I discovered this today by reading the webpack-dev-server code, I have no idea if/where it's documented. It seems to be a feature of webpack-dev-server rather than node-http-proxy itself. Hope that solves it for you. Alastair |
Yeah, looks legit. I heard about this function but never quite understood how to work with it. I tried to return new request object from it instead on reassigning value on referenced object in place. You helped me. Thanks. |
For those like me who are mislead by the current available documentation, the rewrite option in webpack-dev-server 2 beta doesn't exist anymore. devServer: {
port: 80,
proxy: {
'/api/*': {
host: 'api.io',
target: 'http://192.168.33.13/',
pathRewrite: {
'/api' : ''
}
}
}
} |
Consider the config below. By default webpack-dev-server will proxy
/api/
requests tohttp://api.io/api/
. I need to make it pass/api/
requests tohttp://api.io
. I there any way to achieve this? I tried to look into into bypass and rewrite settings on proxyOptions but i seems that they aren't suited for this particular use case. For example, if I directly remove/api/
in bypass function it will just pass request to the next middleware in webpack-dev-server instead of requesting target.The text was updated successfully, but these errors were encountered: