Route Handlers error
Answered
Mandarin fish posted this in #help-forum
Mandarin fishOP
I'm trying to create protected router through route handlers but I'm getting the error "TypeError: module1.render is not a function".
This is my code:
What am I doing wrong?
This is my code:
export async function GET(request: NextRequest) {
const auth = getAuth(firebase_app);
onAuthStateChanged(auth, (user) => {
if (user) {
return NextResponse.next()
} else {
return NextResponse.redirect("/")
}
})
}What am I doing wrong?
3 Replies
You seem to confuse middleware and route handlers
you need to put this code in the root middleware
Answer
".next()" doesn't make sense in a route handler as there is nothing "next"