Replies: 2 comments 10 replies
|
You should be able to leverage export async function getServerSideProps(context) {
const cookies = parseCookies(context);
if (cookies.some_value) {
context.res.writeHead(303, { Location: "/your-page" });
context.res.end();
}
return { props: {} };
} |
10 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.
Hello members,
Following is problem set: I have a form on
/contactpage. I want to check if user filled this form or not. On form submission, I set a local cookie for 24 hours using Ncookies. I want to perform redirection based on this cookie. If cookie is present, user can access any page, otherwise redirect to/contactpage. I managed to setup redirection on client-side, but I see a flicker. What is the best way to setup redirection on server side?I have
componentsfolder for each section likeTwoColumnsLayout,ThreeColumnsLayoutwhich are rendered inpagesfolder. I am unable to leveragegetInitialPropsin each page and perform rendering at server side. Any ideas?Following is code on how I handle redirection on client-side:
All reactions