The redirect API might be somehow error-prone and opaque: is there an alternative? #67749
Unanswered
syenchuk
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Magic methods like
redirect()are confusing and unpredictable, and easily lead to programming errors.redirect()cannot be used in atry / catchblock, unless adding specific boilerplate code to handle the issue (by using the undocumented isRedirectError function).There is NextResponse.redirect but it doesn't work in server-side components (only in routes and middlewares).
The painpoint seems to be similar to how
cookies()work: you cannot always usecookies()to write cookies, depending on some conditions.Is there a discussion going on about how to address these issues?
Beta Was this translation helpful? Give feedback.
All reactions