I'm trying to proxy my a request with dynamic query parameters, but seem to either get a 404 error or no response at all. This is what I've tried so far:
'/services/app/details.json?id=*': {
target: 'https://website.com/api/v1/potato/',
changeOrigin: true,
secure: true,
pathRewrite: {
'^/services/app/details.json?id=': '',
},
}
I'm expecting the request from my local machine (/services/app/details.json?id=2189) to proxy to https://website.com/api/v1/potato/2189 however it seems that the id is not appended to the target request and results in a 404 error.
I tried using the bypass method to append the id myself which instead gives me no response object.
'/services/app/details.json?id=*': {
target: 'https://website.com/api/v1/potato/',
changeOrigin: true,
secure: true,
pathRewrite: {
'^/services/app/details.json?id=': '',
},
bypass(req, res, proxyOptions) {
const id = (req.query.id ? req.query.id : '');
const API = Object.assign({}, proxyOptions, {
target: proxyOptions.target + id,
});
return API.target;
},
}
Does anyone have experience with this?