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: {},
};
} |
Beta Was this translation helpful? Give feedback.
7 replies
-
IMO you should consider something like:
|
Beta Was this translation helpful? Give feedback.
4 replies
-
Opened a RFC for redirecting here: #14890 |
Beta Was this translation helpful? Give feedback.
0 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
page
ingetInitialProps
. if the user is not authenticated, i'm redirecting him to another page.I read the documentation of
getServerProps
and 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!
Beta Was this translation helpful? Give feedback.
All reactions