What is the recommended way of doing redirects inside api routes (try/catch block).
Unanswered
West African Crocodile posted this in #help-forum
West African CrocodileOP
According to docs you can't use redirect or NextResponse.redirect?
1 Reply
@West African Crocodile According to docs you can't use redirect or NextResponse.redirect?
You can use redirect and nextResponse.redirect.
Redirect mostly works in Route handler but if you plan to use redirect in a try catch block, do it like this:
Redirect mostly works in Route handler but if you plan to use redirect in a try catch block, do it like this:
redirect throws an error that Next.js catch and process but if you put it in a try catch you 'd have to rethrow it again