https://supertokens.com/ logo
#support-questions
Title
# support-questions
g

gitcommitshow

04/30/2022, 6:42 PM
I am working on handling expired sessions in express. I used
verifySession
middleware. When the token is expired, it sends 401 response with json response
{"message":"try refresh token"}
. Instead of this, I want to send an html page. So I decided to use
onUnAuthorised
event in SuperTokens node sdk.
Copy code
Session.init({      
  errorHandlers: {        
    onUnauthorised: async (message, request, response) => {                             console.log(message);        
       // But this didn't print anything
    },
....
To test the fn, I logged but I didn't see anything printed in console. 1. Am I using 'onUnAuthorised' event correctly? 2. Is 'onUnAuthorised` event the correct place to override the behaviour on token expiry? Do we have any example or reference for this event?