Menttis
Menttis
NNuxt
Created by roobr on 5/19/2024 in #❓・help
Nuxt 3 Supabase serverSupabaseUser(event) returning NULL
Ok, thanks. I ended up doing the checks in the server API post file. Just passed the role and jwt values from Pinia state to there in body. But middleware would be more elegant solution.
4 replies
NNuxt
Created by roobr on 5/19/2024 in #❓・help
Nuxt 3 Supabase serverSupabaseUser(event) returning NULL
Hi, did you ever get this sorted? I'm having the same issue, trying to secure server routes with middleware:
import { serverSupabaseClient } from '#supabase/server'
import { serverSupabaseUser } from '#supabase/server'
import { serverSupabaseSession } from '#supabase/server'

export default defineEventHandler(async (event) => {
const supabase = await serverSupabaseClient(event);
const user = await serverSupabaseUser(event)
const session = await serverSupabaseSession(event)

console.log('USER ' + JSON.stringify(user)) // Returns null
console.log('SESSION' + JSON.stringify(session)); // Returns null

})
import { serverSupabaseClient } from '#supabase/server'
import { serverSupabaseUser } from '#supabase/server'
import { serverSupabaseSession } from '#supabase/server'

export default defineEventHandler(async (event) => {
const supabase = await serverSupabaseClient(event);
const user = await serverSupabaseUser(event)
const session = await serverSupabaseSession(event)

console.log('USER ' + JSON.stringify(user)) // Returns null
console.log('SESSION' + JSON.stringify(session)); // Returns null

})
4 replies