Next.js Discord

Discord Forum

Redirect issue in getServerSideProps

Answered
Ruwbix posted this in #help-forum
Open in Discord
Avatar
RuwbixOP
Hi I have the following code in getServerSideProps:
 if (!params?.destination || typeof params.destination !== 'string') {
    // Handle invalid or missing destination
    return {
      redirect: {
        destination: '/test',
        permanent: false,
      },
    };
  }


however, it does not seem to redirect correctly, instead it just redirects to /error.
Image
Answered by Sohel Shekh
I have been using redirect as
 redirect("/test")

Try this!
View full answer

1 Reply

Avatar
Sohel Shekh
I have been using redirect as
 redirect("/test")

Try this!
Answer