Doesn't seem to recognize non proxy routes (express)
See original GitHub issueExpected behavior
When setting up an express router, routes not in proxy context are not recognized. IE if filter function returns false, non proxy routes in sub application should be found.
Actual behavior
404 for routes in sub application
Setup
- http-proxy-middleware: 0.17.0
- server: express
- other relevant modules
proxy middleware configuration
var filter = function (pathname, req) {
return pathname.match(new RegExp('^/api'));
};
var apiProxy = proxy(filter, {target: 'http://www.example.org:8000'});
server mounting
var sub = new express.Router();
sub.use(proxy);
// main app, mount the sub application
var app = express();
app.use('/sub', sub);
other route in sub application
sub.get('/someroute',
function(req, res, next) {
// won't find route
}
);
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Cannot seem to get proxy working in Node Express and React ...
I need to proxy between them. I am using http-proxy-middleware to create the proxy and I can see that the proxy is being...
Read more >Reverse port binding in Node.js - Passenger Library
If the app tries to create multiple HTTP servers, then Passenger doesn't know which http.Server object to apply the port binding on.
Read more >5.x API - Express.js
You can use this mechanism to impose pre-conditions on a route, then pass control to subsequent routes if there is no reason to...
Read more >How To Unit Test Express Routes - Marc Littlemore
In this case, writing tests which assert that the specified routes apply your security middleware feel like an ideal use case for writing...
Read more >Using Express.js in Production: Performance Best Practices
If you're using a reverse proxy with Nginx, you can enable it at that level instead. That's covered in the Enabling Gzip Compression...
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 FreeTop 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
Top GitHub Comments
@chimurai absolutely.
https://github.com/newmanw/hpm-sub
Proxy works: ‘http://localhost:3000/sub/api’ Cannot hit ‘http://localhost:3000/sub/hello’
Just pushed v0.17.1 with the fix.
Thanks for reporting the issue and helping out with debugging. Greatly appreciated!