2022-10-09 22:30:32 +02:00
|
|
|
import { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
|
import httpProxyMiddleware from "next-http-proxy-middleware";
|
2023-04-25 23:39:57 +02:00
|
|
|
import getConfig from "next/config";
|
2022-10-09 22:30:32 +02:00
|
|
|
|
|
|
|
|
export const config = {
|
|
|
|
|
api: {
|
|
|
|
|
bodyParser: false,
|
|
|
|
|
externalResolver: true,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2023-04-25 23:39:57 +02:00
|
|
|
const { apiURL } = getConfig().serverRuntimeConfig;
|
|
|
|
|
|
2022-10-24 12:11:10 +02:00
|
|
|
export default (req: NextApiRequest, res: NextApiResponse) => {
|
|
|
|
|
return httpProxyMiddleware(req, res, {
|
|
|
|
|
headers: {
|
2023-03-04 23:29:00 +01:00
|
|
|
"X-Forwarded-For": req.socket?.remoteAddress ?? "",
|
2022-10-24 12:11:10 +02:00
|
|
|
},
|
2023-04-25 23:39:57 +02:00
|
|
|
target: apiURL,
|
2022-10-09 22:30:32 +02:00
|
|
|
});
|
2022-10-24 12:11:10 +02:00
|
|
|
};
|