node-http-proxy

proxy URL manual handling

node-http-proxy automatically proxy based on req.url

which means your proxy endpoint will be ${target} + ${req.url}

if you want to request manually then you need to do req.url = '' and add URI after ${target} before request

something like

router.use('/some-url', (req: Request, res: Response) => {
  const targetUri = // doing some magic with req.originalUrl;
  req.url = '';
  httpProxyInstance.web(req, res, {
    target: `${targetHost}${targetUri}`,
  });
});

custom response

Last updated

Was this helpful?