I created supabase client and pass reference to supbase into fetch function, this is worker:
addEventListener(“fetch”, (event) => {
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
event.respondWith(handleRequest(event.request, {supabase:supabase}));
});
async function handleRequest(request, obj) {
...
else if (request.url.includes("script.js")) {
return new Response(js(request, obj.supabase), {
headers: { "content-type": "text/javascript" },
});
...
inside my script I realize my algorithm, supabase operation need to my algorithm, something like this
const js = (request, supabase) => {
return `
send = document.getElementById('send')
send.supabase=${supabase}
....
}});`
}
export default js;
without supabase all working fine, but I watch my script in browser now and see
const send = document.getElementById('send')
send.supabase=[object Object]
How to receive reference in this place instead object?