What simplest way to pass reference to supabase into Worker script

I asked this question (with good formatting) there https://www.sitepoint.com/community/t/how-to-pass-reference-to-supabase-instead-object-in-cloudflare-worker/451831# What I doing wrong? How can I inject reference to Supabase into my script?
SitePoint Forums | Web Development & Design Community
How to pass reference to supabase instead object in Cloudflare worker
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....
3 Replies
rcoopr
rcoopr2mo ago
well you can't serialise supabase so you can't send a 'reference' like that. you should create a new supabase client in your worker
Viacheslav
Viacheslav2mo ago
@rcoopr thanks, but I don't understand in that way how to add supabase to my worker script if I add to HTML <script src="https://unpkg.com/@supabase/supabase-js@2"></script> ad than inside worker script write: import { createClient } from 'jsr:@supabase/supabase-js@2' I receive error: Module source URI is not allowed in this document: “jsr:@supabase/supabase-js@2”. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at jsr:@supabase/supabase-js@2. (Reason: CORS request not http). this message appears before "Module source URI is not allowed in this document: “jsr:@supabase/supabase-js@2”.
rcoopr
rcoopr2mo ago
I think you need to bundle the supabase lib into your worker yourself
Want results from more Discord servers?
Add your server