Skip to content

Commit

Permalink
Updates supertokens example app SSR behaviour (vercel#43218)
Browse files Browse the repository at this point in the history
Co-authored-by: Rishabh <rishabh@supertokens.io>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
  • Loading branch information
3 people authored and jankaifer committed Nov 23, 2022
1 parent c97a12b commit 7fa46ec
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/with-supertokens/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ 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' } }
} else if (err.type === Session.Error.UNAUTHORISED) {
// 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 {
Expand Down

0 comments on commit 7fa46ec

Please sign in to comment.