How to "next" (skip middleware) based on the response?
See original GitHub issueI have a setup such as:
app.use('/', proxy({
changeOrigin: true,
target: PRERENDERED_APP_URL
}));
app.use('/', proxy({
changeOrigin: true,
target: APP_URL
}));
If PRERENDERED_APP_URL
responds with an error (e.g. status 404), I want to delegate the request to the next route. I do not see “next” as an option in the onProxyRes
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Any way to conditionally skip middleware with next() in express?
My goal is to skip unnecessary middleware if information is already cached from previous routes. So in above example, feature2 doesnt have to ......
Read more >Using middleware - Express.js
To skip the rest of the middleware functions from a router middleware stack, call next('route') to pass control to the next route. NOTE:...
Read more >How to skip a middleware in Express.js ? - GeeksforGeeks
Step 1: Initialize node project. npm init · Step 2: Install required modules npm install express.
Read more >Skipping middleware in Express.js - Tutorialspoint
Skipping middleware in Express.js - You need to pass some parameters to skip the middleware in an Express application.
Read more >Advanced Features: Middleware - Next.js
Middleware allows you to run code before a request is completed, then based on the incoming request, you can modify the response by...
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 some news here?
If you want I can work on it, this feature its very important for us to allow our mock server to have a fallback in case that the proxied server returns some 4XX or 5XX http codes
@gajus I managed to do my thing I made a document about my solution. I didn’t have much time to do that so it’s quick’n’dirty but it works for my case: how to take a JSON response from the proxy and modify it before answering the request using route middlewares.
I’m not sure it will help you but you can look at my solution it may give you ideas. Don’t hesitate to mail me if you need some hints.