Redirect issue in getServerSideProps
Answered
Ruwbix posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/166144585544892417/0a4a916f6aa5d84a7e5342fd5fb1281c.webp?size=256)
RuwbixOP
Hi I have the following code in getServerSideProps:
however, it does not seem to redirect correctly, instead it just redirects to /error.
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](https://cdn.discordapp.com/attachments/1122192366686699662/1122192367215198310/Code_S1erMWckq5.png)
1 Reply
![Avatar](https://cdn.discordapp.com/avatars/166144585544892417/0a4a916f6aa5d84a7e5342fd5fb1281c.webp?size=256)
@Ruwbix Hi I have the following code in getServerSideProps:
tsx
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.
![Avatar](https://cdn.discordapp.com/avatars/756836210550374411/c3efa35c90188476aed80c9d5270dfa3.webp?size=256)
I have been using redirect as
Try this!
redirect("/test")
Try this!
Answer