You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following middleware.ts in a newly created next app using npx create-next-app@latest, running with netlify dev, throws an error:
import { MiddlewareRequest, NextRequest } from '@netlify/next'
export async function middleware(req: NextRequest) {
const request = new MiddlewareRequest(req)
return request.next()
}
The error:
Error: MiddlewareRequest only works in a Netlify Edge Function environment
at middleware (middleware.ts:7:18)
5 | export default async function middleware(req: NextRequest) {
6 |
> 7 | const request = new MiddlewareRequest(req)
| ^
8 |
9 | return request.next()
10 | }
I'm aware this is a copy of #2003, but the solution given -- use netlify dev instead of next dev -- does not seem to work (anymore).
Maybe something to do with new both React and Next versions with major upgrades?
This feature is important to me, it determines whether to switch from Vercel or not...
EDIT: The same error occurs when running a build. The build itself completes without errors, but the app throws a 500 with the same error message as above.
The text was updated successfully, but these errors were encountered:
The following
middleware.ts
in a newly created next app usingnpx create-next-app@latest
, running withnetlify dev
, throws an error:The error:
I'm aware this is a copy of #2003, but the solution given -- use
netlify dev
instead ofnext dev
-- does not seem to work (anymore).Maybe something to do with new both React and Next versions with major upgrades?
This feature is important to me, it determines whether to switch from Vercel or not...
EDIT: The same error occurs when running a build. The build itself completes without errors, but the app throws a 500 with the same error message as above.
The text was updated successfully, but these errors were encountered: