The below code show an error in the Next.js project.
Argument of type 'NextApiRequest' is not assignable to parameter of type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'. Type 'NextApiRequest' is missing the following properties from type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>': get, header, accepts, acceptsCharsets, and 29 more.ts(2345)
import session from 'express-session'
import connectMongo from 'connect-mongo'
import type { NextApiRequest, NextApiResponse } from 'next'
const MongoStore = connectMongo(session)
export default function sessionMiddleware(req: NextApiRequest, res: NextApiResponse, next: any) {
const mongoStore = new MongoStore({
client: req.dbClient,
stringify: false,
})
return session({
secret: process.env.SESSION_SECRET ?? '',
resave: false,
saveUninitialized: false,
store: mongoStore,
})(req, res, next)
}
Any solution for the above problem.
