Graphql + Apollo + Nextjs: errorLink for golobal error handling
Unanswered
TienPham posted this in #help-forum
TienPhamOP
Can we force the page to navigate to login page if any query or mutation having Unauthorized error?
4 Replies
Barbary Lion
Yes, we can, first remove all storage data and navigate to login.
@Barbary Lion Yes, we can, first remove all storage data and navigate to login.
TienPhamOP
Do you have any idea to navigate to login if error happen in ssr?
Barbary Lion
getServerSideProps(){
return {
redirect: {
destination: '/login',
permanent: false, // true if this is not temporary redirect
},
};
}
return {
redirect: {
destination: '/login',
permanent: false, // true if this is not temporary redirect
},
};
}
@Barbary Lion getServerSideProps(){
return {
redirect: {
destination: '/login',
permanent: false, // true if this is not temporary redirect
},
};
}
TienPhamOP
Thank you, Ashis, I meant I would like to do that in errorLink for both clent side and server side rendering. Do you have sollution?