-
Hi, I need to proxy request coming from clients, bur in some cases I need to manage the response locally. In case the request contains a specific word (in the example the word "moon", I need to response back and do noto proxy the request:
How can I stop the proxy to process the request? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Think custom filtering is what you're looking for: You'll get something like: createProxyMiddleware((path, req) => {
return !req.url.includes("moon"); // requests with "moon" will be skipped
}, { target: 'https://my.target.node' }); |
Beta Was this translation helpful? Give feedback.
-
Just for reference, I've solved in a simpler way. Just filtered the request before activate the proxy:
|
Beta Was this translation helpful? Give feedback.
Think custom filtering is what you're looking for:
https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/context-matching.md#custom-filtering
You'll get something like: