Proxy rewrite function no longer called in 1.15.0
See original GitHub issueHey there,
in 1.14.1 the following rewrite function worked
proxy: {
'/api/**': {
target: 'http://localhost:9001',
rewrite: function(req) {
req.url = req.url.replace(/^\/api(.+)$/, '$1');
return req.url;
},
ignorePath: false,
changeOrigin: true,
secure: false
}
}
As of 1.15.0 The rewrite function doesn’t get called anymore.
Was there a breaking change with how the rewrite function works? I understand there was a switch in how proxy works but I figured I would have to update to 2.x.x for those changes to manifest.
Thoughts?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Remove matched `/api` path in Webpack proxy - Stack Overflow
I've added the rewrite to the docs. As bypass already passes the response as an argument to the registered handler, I'm unsure how...
Read more >http-proxy - npm
It is then possible to proxy requests by calling these functions. http.createServer(function(req, res) {. proxy.web(req, res, ...
Read more >Go 1.15 Release Notes - The Go Programming Language
A TestMain function is no longer required to call os. Exit . If a TestMain function returns, the test binary will call os....
Read more >nghttpx - HTTP/2 proxy - HOW-TO — nghttp2 1.52.0-DEV ...
In this mode, it works as reverse proxy (gateway) for HTTP/3, HTTP/2 and HTTP/1 clients to backend servers. This is also known as...
Read more >CHANGES — oslo.cache 1.15.0 documentation
Make CacheIsolatingProxy public; Add shields.io version/downloads links/badges into README.rst; add auto-generated docs for config options; Change ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@SpaceK33z @jdkrebs
This line in
http-proxy-middlewarekind of ignores/reverts the rewritten path in your fix. (source)Not sure what the best approach would be to make it backwards compatible.
As alternative, you could use the
.pathRewriteoption offered by HPM. The syntax is slightly different…For more info on
pathRewrite: http-proxy-middleware/recipes/pathRewrite.md@SpaceK33z
I noticed a sudden surge in downloads since v1.15.0 got released and with it also a number of proxy related issues. Feel free to cc me if you need any assistance.
Closing this. This breaking change was not intended to be released in a minor release, but to completely revert this we’d need to revert the whole PR that introduced http-proxy-middleware. This also brought us websocket proxy support, and a lot of other nice options. Also, not that many people seem to use
rewrite. Documentation for the dev-server is updated to reflect this.Thanks for your help @jdkrebs and @chimurai
TL;DR - use
pathRewrite, as documented in http-proxy-middleware.