In pages
I was able to navigate routes on the server by setting up a return statement in getServersideProps()
Before:
export const getServerSideProps = async (context) => {
try {
..........
// If token exists; redirect to '/'
if (token) {
return {
redirect: {
destination: `/`,
permanent: false,
},
props: {
// email, uid, token
}
}
}
} catch (err) {
// either the `token` cookie didn't exist
// or token verification failed
// either way: allow user to stay on page to login
return {
props: {
},
};
}
};
How can I do the same in the app router
build?