Next.js: [nextjs 9 API] how to use Express lib like app.use(...) inside page/api ??

Created on 12 Jul 2019  Â·  4Comments  Â·  Source: vercel/next.js

I came to nextJS 9.0 . I happy easy to use API And Client Together. but I want to move external API into NEXTJS project (page/api) Graphql workfine. but External API Keep IP and location in middleware.

I use lib external API below.
request-ip
express-ip

PS.graphql I use apollo-server-micro and I pass bodyParser:off in graphql

Most helpful comment

@timneutkens – Is there an active PR or RFC for the middleware helper you mentioned? I'd be happy to contribute if help is welcome.

All 4 comments

Code_-_Insiders_DbbI75Oh4t
this way, you could have another file to define the express() and use some common middlewares

We'll be adding a helper for middleware soon.

Adding express will greatly reduce performance of the API endpoint. But I'm going to close this issue as it ignored the issue template.

@timneutkens – Is there an active PR or RFC for the middleware helper you mentioned? I'd be happy to contribute if help is welcome.

For anyone in the future looking for this feature, what you need is probably API Routes.

There's a really good resource here.

Was this page helpful?
0 / 5 - 0 ratings