SvelteKit SSR auth example bug?
Hi,
Reading through the example
src/routes/layout.ts
for cookie-based auth for SvelteKit and SSR at https://supabase.com/docs/guides/auth/server-side/sveltekit, the code in the following section doesn't seem to match the comment / appears to be wrong...?
How does supabase.auth.getSession()
"read session from the LayoutData"? In the SSR case, isn't this replacing the session that was verified in the hooks? If the JWT verification had failed, data.session
would be null but here we return a session from the cookies with no JWT verification anyway? Shouldn't the session assignment look more like:
1 Reply
Yeah, some inconsistencies there.
Personally, I import
isBrowser
from the ssr library and do this. Replace the custom function with (await supabase.auth.getSession()).data.session