Regression: REST Request Missing Authorization Header in Preview Mode

Hi, something I just noticed recently, I have the following code (in a weweb formula) to retrieve supabase token in cookie in order to call supabase function (as it is currently not supported in the plugin). but this formula only works Im editor mode (within workflow editor) and production, once I toggled to preview in editor this cookie becomes null. This really blocks my workflow, any clue of whats going on? Thanks ahead!

function getCookie(name) {
const value = ; ${document.cookie};
const parts = value.split(; ${name}=);
if (parts.length === 2) return parts.pop().split(‘;’).shift();
}
const cookie = getCookie(“sb-access-token”)
if (cookie === null || cookie === undefined || cookie === ‘’) {
return null
}
return "Bearer "+ cookie

Hi @liweihan :wave:

Not sure this will help but here’s a short video on how to get a user’s session token when you’re working with Supabase Auth.

If it doesn’t help, can you share a few screenshots or video to show us how things are setup in WeWeb, to walk us through what seems to be working and what isn’t? :slight_smile:

1 Like

This is it! Thanks for expoing this property!

Hi @liweihan,

I am trying to call a supabase function from Weweb, and I am struggling with the RLS policies. So I wonder why you would need the supabase token to call a function ?

Thanks,

Baptiste