I have a DB trigger to create profiles on auth sig...
# javascript
u
s
What exactly does the trigger do?
u
it's almost identical to this:
Copy code
sql
create function public.handle_new_user() 
returns trigger as $$
begin
  insert into public.users (id, full_name, avatar_url)
  values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url');
  return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.handle_new_user();
s
Oh I'm seeing the first part of your message now, so it creates a profile, this is relatively quick to do so I don't think it would lead to the profile not being ready by the time you reach the next-steps page
How are you retrieving the profile from the DB?
u
hmm, maybe its a slightly different issue then
my
next-steps
page is SSR, with
user
and
profile
both being fetched by the server
but i set the supabaseCookie via a client side api call
s
I think that's where the issue is, the request to the profile is probably happening before the cookie is being set
So it's not sure which user it should be looking for
u
how can I ensure I set the cookie before I navigate via
redirectTo
?
s
I'm doing something hackish in my SvelteKit app (which I'm sure will work in any other SSR framework), I first redirect to a page that then redirects to the next-steps page, so the cookie gets set when I redirect to that page first before moving to the
next-steps
page
u
ah, smart!
s
This hopefully will be fixed in the future as the team is working on something around this from what I can remember. So this step won't be necessary at that point.
I made the first redirect page like a loading screen that just redirects after a few milliseconds
u
thats great, thanks
waiting for the cookie to be set instead of polling is much smarter
s
Yep, mine was even worse because you would log in and couldn't see the protected pages and be redirected back to the login page because I was setting the logged in session based on the cookie being set first.
u
totally makes sense