Set up routing pages for next-connect

478 views Asked by At

I set up a server with next-connect. Now how can I move requests to the pages folder of my nextjs program? This is my server js file:

const nc = require("next-connect");

const {auth} = require("../app/middlewares/auth");

const handler = nc()
.use(auth)
.get((req, res) => {
console.log('->', req.session.get('user'))
// Render the requested page from the pages folder
}).post();

createServer(handler).listen(process.env.PORT);
1

There are 1 answers

1
ABDULLOKH MUKHAMMADJONOV On BEST ANSWER

Looks like you created a custom backend for your Next.js project probably using Node.js and express. This requires some critical changes throughout the project.

You can read the documentation here. https://nextjs.org/docs/advanced-features/custom-server