Created
May 11, 2021 12:56
-
-
Save marxian/8d361038e79757bb65dca2353f114207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextApiRequest, NextApiResponse } from "next"; | |
import httpProxyMiddleware from "next-http-proxy-middleware"; | |
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | |
export default (req: NextApiRequest, res: NextApiResponse) => | |
httpProxyMiddleware(req, res, { | |
target: process.env.API_HOST, | |
changeOrigin: true, | |
headers: { | |
Authorization: `Bearer ${process.env.API_TOKEN}`, | |
}, | |
pathRewrite: { | |
"^/api/": "", // strip our 'api' path from the front of the url | |
}, | |
}); | |
export const config = { | |
api: { | |
bodyParser: false, | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment