Repository navigation
Replies: 3 comments 11 replies
|
You are able to redirect in export async function getServerSideProps(context) {
if (context.res) {
// server
context.res.writeHead(302, {
Location: '/',
});
context.res.end();
}
return {
props: {},
};
} |
7 replies
|
IMO you should consider something like: |
4 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
Today, I'm performing authentiocation checks of a
pageingetInitialProps. if the user is not authenticated, i'm redirecting him to another page.I read the documentation of
getServerPropsand saw the recommendation to use it and notgetInitialProps.But, how can I implement server side redirect with
getServerProps?Of course I can't use both in the same page.
Maybe it is fine to use some wrapper HOC to the Page component and there define
getInitialProps?thanks!
All reactions