NestJS with Supabase Auth SSR package
Hey, I'm new to Supabase and its community. Would appreciate some guidance
I'm trying to implement this logic below defined in SSR package docs for express, but in NestJs backend. Is there anyone who managed to implement this?
I'm trying to implement this logic below defined in SSR package docs for express, but in NestJs backend. Is there anyone who managed to implement this?
const { createServerClient } = require('@supabase/ssr')
exports.createClient = (context) => {
return createServerClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY, {
cookies: {
get: (key) => {
const cookies = context.req.cookies
const cookie = cookies[key] ?? ''
return decodeURIComponent(cookie)
},
set: (key, value, options) => {
if (!context.res) return
context.res.cookie(key, encodeURIComponent(value), {
...options,
sameSite: 'Lax',
httpOnly: true,
})
},
remove: (key, options) => {
if (!context.res) return
context.res.cookie(key, '', { ...options, httpOnly: true })
},
},
})
}