What is the proper way to set up a route with next pages?

The docs don't paint a full picture and I'm confused. Allegedly, photo one is how the route is supposed to look, but when I use that route I get an internal server error when navigating to it and the following error:

[ERROR] N [Error]: The middleware "/api/oauth/apple/login" accepts an async API directly with the form:


export function middleware(request, event) {
return NextResponse.redirect('/new-location')
}

However, when I use the 2nd route, the page loads fine however I don't have access to the environment variables I've set in .dev.vars
Was this page helpful?