Let's say I have a login, signup and home page. I want the home page to be gated ( require a logged in user to see it ) Are you creating an "On load" lifecycle event? ( if so, how are you doing this? I keep getting stuck on a switch statement ) Or are you making an API call and having the success do nothing, or maybe just store something and have the error flow use the "Go to URL" action? Thinking of the best way to do it, but interestingly I just can't get my head around getting the "On load" even working as I'm checking the session cookie and that doesn't seem to be working...
I have Supabase auth setup and working correctly for reference with the access_token being stored in the session cookies.
Chris Laupama
3 months ago
Aug 21, 2024, 9:25 AM
ATM - the route I think I'm going to take is just to make an API auto-fetch call to the supabase "GET USER" endpoint. If successful do nothing. If error - trigger the "GO TO URL" action. --- I'm just thinking that since I have the session cookie stored, surely I can use that... just check for that in the "On load" lifecycle event.
Max
3 months ago
Aug 21, 2024, 9:41 AM
Hi Chris! You cannot check the session cookie on load. On load happens in the browser and this is an http cookie, so you won't be able to access it
That is one option. Another one is to use the new get cookie in a formula that evaluates server side. Could work, but I haven't tried it yet
Erik Beuschau
3 months ago
Aug 21, 2024, 9:45 AM
With the new APIs we're rolling out (soon), you will be able to setup server-side redirect rules based on an API's response, it's statuscode or a cookie provided by the client.