Different refresh outcomes on different environments

I'm using clojurescript with supabase, and, when running on local (watch), supabase automatically refreshes the token whenever it expires. This is consistent, even if I exit the page and enter long after the token expires. The problem is that this doesn't happen when I bundle the project in a static file. Login and other auth operations work flawlessly, of course, just the refresh flow jusn't happen, right after the first expiration. What I think is happening: Since in local I'm running a constant watch, supabase might keep a state, even if the page isn't running on a browser. So it knows that a token needs refresh just based on the server state. Which doesn't happen when deployed, since Supabase just exists as long as a page is open.
5 Replies
j0suetm
j0suetmOP2y ago
By the way, clojurescript transpiles to Javascript, so at the end, im using the supabase-js lib.
garyaustin
garyaustin2y ago
Not really understanding your environment, but Supabase uses local storage to restore the user session when you come back later. By default it also expects local storage and will do strange things if run without it unless you set persistSession:false in createClient.
j0suetm
j0suetmOP2y ago
Thank you for your time, I appreciate it! watch (dev): npm + shadow-cljs: constantly watching for .cljs file and generating the transpiled js files. static (prod): a literal html file that imports the bundled minified global js file. on watch (dev) environment, the server may update the client, but most functions keep as is, since the first call, including supabase, which I suppose is what's causing the non-refreshing problem on the static (prod) env. Anyways, the localStorage and cookies work correctly on both environments, the only problem is that on the static (prod) env, supabase doesn't refresh on token expiration, while it does on the watch (dev) env.
garyaustin
garyaustin2y ago
If you have localstorage support on the production environment then not sure what could cause lack of refresh. Note the refresh is not done on expire, but is done using a timer set to go off before the token expires.
j0suetm
j0suetmOP2y ago
my problem was with CORS, I fixed it, thank you again!
No description

Did you find this page helpful?