Unverified Commit 08ee7b22 authored by Rishabh Poddar's avatar Rishabh Poddar Committed by GitHub

Updates supertokens example app SSR behaviour (#43218)

Co-authored-by: 's avatarRishabh <rishabh@supertokens.io>
Co-authored-by: 's avatarBalázs Orbán <info@balazsorban.com>
parent 807c59a2
......@@ -16,7 +16,11 @@ export async function getServerSideProps(context) {
supertokensNode.init(backendConfig())
let session
try {
session = await Session.getSession(context.req, context.res)
session = await Session.getSession(context.req, context.res, {
overrideGlobalClaimValidators: async function () {
return []
},
})
} catch (err) {
if (err.type === Session.Error.TRY_REFRESH_TOKEN) {
return { props: { fromSupertokens: 'needs-refresh' } }
......@@ -24,11 +28,8 @@ export async function getServerSideProps(context) {
// this will force the frontend to try and refresh which will fail
// clearing all cookies and redirecting the user to the login screen.
return { props: { fromSupertokens: 'needs-refresh' } }
} else if (err.type === Session.Error.INVALID_CLAIMS) {
return { props: {} }
} else {
throw err
}
throw err
}
return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment