I have been developing a Next.js application that includes a login form for user sign-in. To handle server-side redirection after successful sign-in, I have integrated the redirect function from next/navigation. However, during testing, I came across the following error:
Sign-in error: Error: NEXT_REDIRECT
at getRedirectError (redirect.js:49:19)
at redirect (redirect.js:60:11)
at handleSignIn (cognitoActions.ts:87:13)
at async eval (login-form.tsx:38:34)
Let me share my current code setup with you:
LoginForm component:
The LoginForm component has various imports and functions for handling user sign-in using React hook forms and Cognito actions.
handleSignIn function:
The handleSignIn function is responsible for signing in users and handling any additional steps required such as confirming sign-up codes.
Despite setting up the redirection on the server side, I am still encountering the NEXT_REDIRECT error. Can someone guide me on how to troubleshoot this issue and implement proper server-side redirection without errors?