-
Notifications
You must be signed in to change notification settings - Fork 878
Description
Is this a question?
Yes!
I made a StackOverflow post for this question but it's been over 2 weeks now with no response, so I'm hoping I can get some help here.
I have some dynamic route namespaces defined by a config file. A config entry looks like this:
catalog:
name: catalog
address: https://catalog.foo.co
type: page
version: v1When the browser makes a request to /catalog/assets/styles.css, the proxy should send that request to https://catalog.foo.co/v1/assets/styles.css. I've tried multiple ways to configure the proxy, as shown in the SO post, but none of them work. I see no evidence that the requests are even reaching the proxy code, since I've added hooks like the one below without observing any console output:
onProxyReq: (proxyReq, req, res) => {
console.log("Hello I'm being proxied now! ", proxyReq, req, res);
},The server just responds with a 302. The proxy works fine for other routes I've defined, but I can't figure this one out.
I do have this proxy working using the request library with this code:
const assets = express.Router();
app.use(`/${p.name}/assets`, assets);
assets.get('*', async (req, res) => {
return request(`${p.address}/${p.version}/assets${req.path}`).pipe(res);
});I'm just not sure how to correctly adapt it to use the http-proxy-middleware. Help is appreciated, thanks!