Anyone familiar with Nuxt3 & Supabase here? I'm ho...
# help
h
Anyone familiar with Nuxt3 & Supabase here? I'm horrendously stuck setting up authentication for Nuxt's API to work together with Supabase. 😬
🙌 thank you @User . Here's my repo without the API set up: https://github.com/henningko/briefxyz This works ok (but certainly is not true to form, particularly wrt TypeScript). However, I want to stop rendering the markdown on the frontend (to avoid risk of xss, and for performance reasons), so I created an Nuxt API endpoint that pulls the content from Supabase and renders it. For the authentication, I have created an
/api/auth
endpoint that sets a cookie based on https://supabase.com/docs/reference/javascript/auth-setauth .
api/auth
is called with
onAuthStateChange()
. However, when logging in, the app tries to fetch content from
/api/get
before the cookie is returned, thus failing with the request. What's an elegant way to handle the login and protect pages?
Alright, I was able to clean it up a ton and ended up introducing a
isAuthenticated
method in a composable, that checks if the supabase authentication has completed and the API has set the cookie. This largely works, however, I'm getting a "Auth session missing!" when loading, possibly because when the server side tries to hydrate?