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.
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.I can't even get it to work with the code above.
For a workaround, I found this comment.
I made the
catch
to return the following snippet, and I removedres.writeHead(302, { Location: '/profile' })
andres.end()
.