I'm getting an error when trying to run very basic middleware in my Next 12.1.0 app.
I have a file called /pages/_middleware.tsx with the following very basic code:
import type { NextRequest } from 'next/server'
import { NextResponse } from 'next/server'
export default (req: NextRequest, response: NextResponse) => {
console.log('running basic middleware')
}
It all works fine locally, but when I push to Vercel I'm getting this build error:
Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware
I don't understand, because there's obviously no dynamic code evaluation happening. Could it be that middleware in 12.1.0 is broken on Vercel because it was a beta feature?
Thanks!