Access_token Expiration handler
I am currently in the process to handle the expiration of the access _token provided by supabase . In an application where the HTTPonly flag is not set , you can just read the access _tokens expiration time and redirect the user to the login . Alternatively , I could send an API request to a specific endpoint before the token expires to verify the token is valid and return a new access _token to have a seemles experience . How can something like this be done with supabase + toddle ? Since the HTTPonly flag is checked , I cant read the expiration time of the token using a custom function . So I thought I just store the expiration time in local storage every time the access _token is set and check it periodically - then renew the access _token every time the token is about to expire . To do this , I found the sb _refresh _token what should be exactly for this purpose - however I am unable to read that as well due to the HTTPonly flag and found no toddle native way to use that in the payload . What can I do to not have my app just break when the token expires ? The only alternative I see is : - store expiration time in local storage - once expiration time is about to be exceeded , "logout " the user automatically I decided against a infinite loop that constantly checks a timestamp . In theory , it does not matter if you store the timestamp by yourself or if you somehow were able to read the JTW from Supabase as example . Main reason for me deciding against it is because it constantly creates load for a very small window where it actually serves its benefit . The solution I go for is I added a check function that looks at the error of an API response and redirects to login if the page you are currently on is considered "login only " content . This function sits in my ENV wrapper component that I am currently putting into a package for better maintenance as I already have to maintain that in multiple projects If you have a specific desired functionaly that you are looking for please let me know , I might be able to add it for the first release of the package . Damn your not the _guy you 're The Guy ! A package like that would be very helpful for the toddle community . I use hosted auth pages from my backend provider . On succesfull login they call my apps "call back " url and pass the auth token and a refresh token . Ideally i would like users to stay logged into my app just as toddle has for example . There must be some auto refresh of the token going on . Do you have a video that shows the problem of the flashing content ? Flashing content can come from different problems There are also multiple ways how to solve this , either on page or component level - I already have something in mind but I would like to know more about the problem you are facing Its a general issue all new toddle builders face . There is an onload api check to auth /me endpoint which on error redirects to another url . Normally you see a flash of the actual content being displayed before the redirect kicks in . Guess it can be solved by putting a loader component on each page that shows only the loader and hides the page content unless auth /me is successful Let me know if this already sufficient : https://www.loom.com/share/142a6de0812442c783f0457eb7dd30be I am currently thinking about not only looking at the auth /me but also looking at API Requests inside the wrapper so the loading screen only is removed when every API that we want to wait for has finished loading The page from the video itself is in progress and might change from what you see in the video , the video should be used as reference . I made the loading screen optional ( as shown in the video ) , its currently turned off - thats why you don 't see it I have enabled it again so now you should be able to replicate the video . What do you mean by when you go back it actually loads the page ? Can you describe this further ?
