Disable Next.js file-system routing for "api" folder

  express, javascript, next.js, routes

I have a custom created API using Express in a folder named api. Also, I have a Next.js app in another folder.

Both my Express api and Next.js app share a lot of logic.

What I need to do is to bring my api folder within Next.js app folder, so I can make common internal modules imported easier.

The problem is that api is a special folder for Next.js such that it applies somehow file-system routing upon it, so it clashes with how Next.js works if I brought my Express api folder.

Is there any way to disable Next.js file-system routing for api folder? (so I can add my own custom Express api folder and route it easily from a custom server that handles both Express and Next.js).

Source: Ask Javascript Questions