An error has been identified in the code for a Next.js project below.
The error message reads: Argument of type 'NextApiRequest' is not assignable to parameter of type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'. Type 'NextApiRequest' is missing certain properties required by 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>', such as get, header, accepts, acceptsCharsets, and 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)
}
https://i.sstatic.net/Ei4x8.jpg
Any suggestions on how to resolve the issue mentioned above?