Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
09a4c9f1
Commit
09a4c9f1
authored
Oct 13, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[skip ci] move next.js api config to proxy route
parent
eac58023
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
next.config.js
next.config.js
+0
-5
proxy.ts
pages/api/proxy.ts
+10
-2
No files found.
next.config.js
View file @
09a4c9f1
...
...
@@ -38,11 +38,6 @@ const moduleExports = {
redirects
,
headers
,
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
);
pages/api/proxy.ts
View file @
09a4c9f1
...
...
@@ -4,7 +4,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
import
fetchFactory
from
'
nextjs/utils/fetch
'
;
import
c
onfig
from
'
configs/app
'
;
import
appC
onfig
from
'
configs/app
'
;
const
handler
=
async
(
nextReq
:
NextApiRequest
,
nextRes
:
NextApiResponse
)
=>
{
if
(
!
nextReq
.
url
)
{
...
...
@@ -14,7 +14,7 @@ const handler = async(nextReq: NextApiRequest, nextRes: NextApiResponse) => {
const
url
=
new
URL
(
nextReq
.
url
.
replace
(
/^
\/
node-api
\/
proxy/
,
''
),
nextReq
.
headers
[
'
x-endpoint
'
]?.
toString
()
||
c
onfig
.
api
.
endpoint
,
nextReq
.
headers
[
'
x-endpoint
'
]?.
toString
()
||
appC
onfig
.
api
.
endpoint
,
);
const
apiRes
=
await
fetchFactory
(
nextReq
)(
url
.
toString
(),
...
...
@@ -29,3 +29,11 @@ const handler = async(nextReq: NextApiRequest, nextRes: NextApiResponse) => {
};
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
,
},
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment