DEV Community

Discussion on: The Complete Guide to Next.js Authentication

Collapse
 
justincy profile image
Justin • Edited

UPDATE: support for redirects in getServerSideProps was released in v10. See the docs for more information about redirects: nextjs.org/docs/basic-features/dat...

OLD: FYI, redirects in getServerSideProps aren't 100% supported and a side-effect of that is they currently cause a full page reload. There's an RFC for redirects to be fully supported.

Collapse
 
paragbaxi profile image
Parag Baxi

I can't even get it to work with the code above.

Collapse
 
wataruoguchi profile image
Wataru Oguchi

For a workaround, I found this comment.

I made the catch to return the following snippet, and I removed res.writeHead(302, { Location: '/profile' }) and res.end().

return {
  redirect: {
    destination: "/profile",
    statusCode: 302,
  },
};
Enter fullscreen mode Exit fullscreen mode