question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't seem to recognize non proxy routes (express)

See original GitHub issue

Expected 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:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
newmanwcommented, Aug 2, 2016
0reactions
chimuraicommented, Aug 11, 2016

Just pushed v0.17.1 with the fix.

Thanks for reporting the issue and helping out with debugging. Greatly appreciated!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found