stegano / next-http-proxy-middleware

HTTP Proxy middleware available in API Middleware provided by Next.js.
237 stars 19 forks source link

Additional headers doesn't write to request #19

Open 3nodecz opened 3 years ago

3nodecz commented 3 years ago

I am experiencing problem that I am not able to add any custom headers. I have made a quick look on your code and I don't see any action with headers on proxy request ...

stegano commented 3 years ago

Hi @3nodecz, You can add custom headers through the http-proxy setting.

Please refer to the source code below 😀

// Custom headers examples
export default (req: NextApiRequest, res: NextApiResponse) => (
  isDevelopment
    ? httpProxyMiddleware(req, res, {
     ...
      headers: {
        HELLO: 'Hello :)', // <- You can add custom headers
      },
    })
    : res.status(404).send(null)
);