So we have a working proxy that redirects local api requests to our dev public api:
server.middleware = proxyMiddleware('http://localhost:3000/platform/api/v2', {
target: 'https://public-api.domain.com',
headers: { host: 'public-api.domain.com' },
pathRewrite: {
'^/platform/api/v2': '/api/v2'
}
});
However we now need another proxy for one specific api call that needs to goto another api server (ie: https://public-api.domain2.com). I'v searched around and tried different ideas, but nothing seems to work. How can this be done?
Can think of 2 ways to do it.
# 1
Create 2 seperate proxies; Use context-matching to include or exclude certain paths.
You can use glob patterns or a custom function in context matching.
server.middleware = [proxyMiddleware(/*... config1 ...*/), proxyMiddleware(/*... config2 ...*/)]
# 2
Create a single proxy and use the router option to route a specific request to a different target
No response... closing issue.
Feel free to re-open.
Most helpful comment
Can think of 2 ways to do it.
# 1
Create 2 seperate proxies; Use context-matching to include or exclude certain paths.
You can use glob patterns or a custom function in context matching.
# 2
Create a single proxy and use the
routeroption to route a specific request to a differenttarget