Skip to content

Instantly share code, notes, and snippets.

@marxian
Created May 11, 2021 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marxian/8d361038e79757bb65dca2353f114207 to your computer and use it in GitHub Desktop.
Save marxian/8d361038e79757bb65dca2353f114207 to your computer and use it in GitHub Desktop.
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