When using the cors example code from the documentation page, it gives typescript error:
TS2345: Argument of type '(req: NextApiRequest, res: { statusCode?: number | undefined; setHeader(key: string, value: string): any; end(): any; }, next: (err?: any) => any) => void' is not assignable to parameter of type 'Middleware<NextApiRequest, NextApiResponse<any>> | Middleware<NextApiRequest, NextApiResponse<any>>[]'. Type '(req: NextApiRequest, res: { statusCode?: number | undefined; setHeader(key: string, value: string): any; end(): any; }, next: (err?: any) => any) => void' is not assignable to type 'Middleware<NextApiRequest, NextApiResponse<any>>'. Type 'void' is not assignable to type 'Promise<void>'.
import { use } from "next-api-middleware";
import cors from "cors";
const apiRouteThatOnlyNeedsCORS = async (req, res) => {
...
}
export default use(cors())(apiRouteThatOnlyNeedsCORS);
Please advice on how to resolve it. Thanks
When using the cors example code from the documentation page, it gives typescript error:
Please advice on how to resolve it. Thanks