I Have a next project when I build it, it works fine localy but on vercel keeps throwing this error no matter what I try
Type error: Route "[action]/route.ts" has an invalid "POST" export:
Type "NextResponse<unknown>" is not a valid type for the function's second argument.
Error: Command "npm run build" exited with 1
This is my current code and I’ve tried many variation of it but it wont let me build
declare module "next/server" {
interface NextResponse {
params: { action: string }; // Add your custom property here
}
}
export const POST = async (req: NextRequest, res: NextResponse) => {
const { params } = await res;
if (!params || !params.action)
return NextResponse.json({ success: false, message: "Incorrect usage" });
const action = params.action;
...
Also tried expanding
interface MyResponse extends NextResponse {
params: { action: string }; // Add your custom property here
}
export const POST = async (req: NextRequest, res: MyResponse) => {
Any help would be much appreciated