Commit 09a4c9f1 authored by tom's avatar tom

[skip ci] move next.js api config to proxy route

parent eac58023
...@@ -38,11 +38,6 @@ const moduleExports = { ...@@ -38,11 +38,6 @@ const moduleExports = {
redirects, redirects,
headers, headers,
output: 'standalone', output: 'standalone',
api: {
// disable body parser since we use next.js api only for local development and as a proxy
// otherwise it is impossible to upload large files (over 1Mb)
bodyParser: false,
},
}; };
module.exports = withRoutes(moduleExports); module.exports = withRoutes(moduleExports);
...@@ -4,7 +4,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'; ...@@ -4,7 +4,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
import fetchFactory from 'nextjs/utils/fetch'; import fetchFactory from 'nextjs/utils/fetch';
import config from 'configs/app'; import appConfig from 'configs/app';
const handler = async(nextReq: NextApiRequest, nextRes: NextApiResponse) => { const handler = async(nextReq: NextApiRequest, nextRes: NextApiResponse) => {
if (!nextReq.url) { if (!nextReq.url) {
...@@ -14,7 +14,7 @@ const handler = async(nextReq: NextApiRequest, nextRes: NextApiResponse) => { ...@@ -14,7 +14,7 @@ const handler = async(nextReq: NextApiRequest, nextRes: NextApiResponse) => {
const url = new URL( const url = new URL(
nextReq.url.replace(/^\/node-api\/proxy/, ''), nextReq.url.replace(/^\/node-api\/proxy/, ''),
nextReq.headers['x-endpoint']?.toString() || config.api.endpoint, nextReq.headers['x-endpoint']?.toString() || appConfig.api.endpoint,
); );
const apiRes = await fetchFactory(nextReq)( const apiRes = await fetchFactory(nextReq)(
url.toString(), url.toString(),
...@@ -29,3 +29,11 @@ const handler = async(nextReq: NextApiRequest, nextRes: NextApiResponse) => { ...@@ -29,3 +29,11 @@ const handler = async(nextReq: NextApiRequest, nextRes: NextApiResponse) => {
}; };
export default handler; export default handler;
export const config = {
api: {
// disable body parser otherwise it is impossible to upload large files (over 1Mb)
// e.g. when verifying a smart contract
bodyParser: false,
},
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment