Jingly
05/22/2022, 9:33 PMsupabaseClient = createClient()
will allow access to one and only one schema. Right now a non-authenticated user will access the public schema. Once authenticated, I want to change the accessed schema. Currently, I just override the supabaseClient with createClient({schema: 'new-schema')
. Is there a better way to go about this approach? Also, will overriding the variable allow the connection to the public schema to remain open?Needle
05/22/2022, 9:33 PMgaryaustin
05/22/2022, 9:53 PMNeedle
05/22/2022, 9:53 PMgaryaustin
05/22/2022, 9:58 PM//Option 1, shell to call if you will need valid token... there are probably "nicer" ways to implement this...
var SUPAbase = async function (sb) {
if (await checkSession() ==='expired') {
let session = supabase.auth.session();
sb.headers.Authorization = `Bearer ${session.access_token}`
}
return (await sb)
}
// call like SUPAbase(supabase.from....)
So I think supabase.headers.content-profile = 'my-schema' before the call might work, where supabase is your client, but have not tested it.Jingly
05/23/2022, 4:23 AMJingly
05/23/2022, 4:24 AMJingly
05/23/2022, 4:25 AMgaryaustin
05/23/2022, 12:13 PM