https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Button ID Undefined Error
    h

    HAHZNFT

    03/10/2023, 7:03 PM
    When I click on an emoji https://til.arvrtise.com i get an ID undefined error.
    g
    g
    • 3
    • 4
  • Policy to make sure the inserted row does not have a matching ID between user_id <> followee_id
    v

    Vik

    03/10/2023, 7:27 PM
    I'm trying to create a policy on my
    followers
    table to ensure that the
    use_id
    and
    followee_id
    can not be the same user ID. Meaning they can not be following or follow themselves. But with my current policy it still allows me to insert a row with those columns having matching IDs.
    g
    • 2
    • 8
  • Analytics/tracking page views
    c

    cfofiu

    03/10/2023, 7:33 PM
    Has anyone built simple analytics (i.e. tracking clicks and page views) with Supabase (say using Next.js) similar to Google Analytics? Can Supabase handle a lot of traffic?
    b
    g
    • 3
    • 6
  • JavaScript deployment to Vercel issue
    s

    SomGG

    03/10/2023, 7:39 PM
    Hey everyone, I have an HTML and JavaScript project and I have already set up Supabase with it. It's working fine locally, but it doesn't work on Vercel even though I have defined the Environment Variables in Vercel. Am I missing something?
    g
    g
    • 3
    • 7
  • Realtime presenceState is an empty object with sync event
    d

    Deed

    03/10/2023, 8:32 PM
    Hi, I'm wondering if I'm doing something wrong with real time here. The console log simply gives me an empty object. Is this normal, or am I missing something?
    Copy code
    const _showChannelPresence = supabase
        .channel("show-presence")
        .on("presence", { event: "sync" }, () => {
          const state = _showChannelPresence.presenceState();
          console.log(state);
        }).subscribe();
    g
    b
    • 3
    • 9
  • Infinite recursion detected for select policy
    v

    Vik

    03/10/2023, 9:27 PM
    I need some help creating a policy for my
    followers
    table. The current structure for my
    followers
    table goes like this:
    Copy code
    Row: {
    approved: boolean | null;
    created_at: string;
    follow_id: string;
    followee_id: string;
    user_id: string;
    };
    followee_id
    and
    user_id
    are composite keys that relate to the
    profiles.id
    profiles
    is setup like so:
    Copy code
    Row: {
    about: string | null;
    avatar_url: string | null;
    id: string;
    joined: string;
    location: string | null;
    name: string | null;
    onboarded: boolean;
    private: boolean;
    username: string;
    };
    The select policy that I'm working on should allow if:
    auth.uid() = user_id
    auth.uid() = followee_id
    OR The account is not private OR The account is private but an approved
    followers
    row exists. This is what I currently have but I'm getting an infinite query error. What am I doing wrong with the check?
    Copy code
    (
      (auth.uid() = user_id) OR 
      (auth.uid() = followee_id) OR 
      (
        exists(
          select 1 from profiles
          where profiles.id = followee_id
          and (profiles.private = false OR exists(
            select 1 from followers
            where followers.followee_id = profiles.id
            and followers.user_id = auth.uid()
            and followers.approved = true
          ))
        )
        OR 
        exists(
          select 1 from profiles
          where profiles.id = user_id
          and (profiles.private = false OR exists(
            select 1 from followers
            where followers.followee_id = auth.uid()
            and followers.user_id = profiles.id
            and followers.approved = true
          ))
        )
      )
    )
    g
    • 2
    • 9
  • Supabase service_role access lacks pgsodium permissions
    c

    cagey

    03/10/2023, 9:36 PM
    I am adding an encrypted column to a table following the guidance here: https://supabase.com/blog/transparent-column-encryption-with-postgres I am accessing Supabase via Cloudflare Workers, so I am using the service_role key for my requests, but despite that I get
    permission denied for function crypto_aead_det_encrypt
    when attempting to create a new pgsodium key. I can successfully add rows to the same table via the online SQL editor. The relevant SQL is:
    Copy code
    CREATE TABLE secret (
      name TEXT NOT NULL,
      account_id uuid NOT NULL,
      key_id uuid NOT NULL REFERENCES pgsodium.key(id) DEFAULT (pgsodium.create_key()).id,
      nonce bytea NOT NULL DEFAULT pgsodium.crypto_aead_det_noncegen(),
      contents text NOT NULL,
      CONSTRAINT fk_account FOREIGN KEY(account_id) REFERENCES account(id),
      PRIMARY KEY(name, account_id)
    );
    
    SECURITY LABEL FOR pgsodium
      ON COLUMN secret.contents
      IS 'ENCRYPT WITH KEY COLUMN key_id NONCE nonce ASSOCIATED (name, account_id)';
    h
    s
    • 3
    • 12
  • New account stuck - no email verification recieved
    h

    habanero

    03/11/2023, 12:35 AM
    I've created an account but I have not received the verification email. I've checked all the usual places - spam folder, etc. The email address I signed up with is a forward from CloudFlare, and CloudFlare doesn't record ever seeing an email from Supabase. Is there anyone at Supabase that is able to help me get signed up?
    g
    • 2
    • 2
  • Anyone seen a report on how much s3 file storage space you have used?
    g

    garyaustin

    03/11/2023, 1:11 AM
    I've not found it, if it exists.
    l
    • 2
    • 6
  • Can't fetch data linked with merge table correctly
    l

    Lukas

    03/11/2023, 1:15 AM
    I have a function (picture 1) thats meant to fetch the classes a user is in. There is a merge table (picture 2) and an asssignments table and a classes table (pictiures 3 and 4 respectivly) For some reason, it always returns the same class (lake viewing) even though they aren't linked correctly. Fetching the merge table returns the correct class. Does anyone know what the issue is here
    g
    s
    • 3
    • 46
  • Is it Safe to expose the anon key to the browser if I don't have RLS on?
    r

    robipop22

    03/11/2023, 1:20 AM
    my use case is that I have 2 api routes that are writing into my DB and I can't enable RLS for that reason, can I somehow verify the update to the DB so if someone gets my anon key cannot insert data ?
    g
    l
    • 3
    • 12
  • Flutter project gives "Invalid Refresh Token: Refresh Token Not Found" error
    h

    heedongcho-xyz

    03/11/2023, 2:56 AM
    A Flutter project that worked fine all along started giving me this error. I get this right after my Supabase client is initialized. I tried using .handleError() and .refreshSession(), as well as deleting all the users in my database, but neither give any results. And because of the error I haven't been able to display my app at all...
    g
    • 2
    • 2
  • Supabase, Vercel and ERR_NAME_NOT_RESOLVED
    u

    ローリー Laurie

    03/11/2023, 5:51 AM
    I have a project deployed to vercel making requests to a supabase database using the javascript library. Recently I'm getting this error and none of the requests go through. I haven't touched the code. Does anyone know what the cause might be?
    s
    • 2
    • 1
  • Upsert Error Supabase
    s

    STILLWATER;

    03/11/2023, 10:09 AM
    Im getting the same error on upsert in supabase:
    Copy code
    json
    {"code":"21000","details":null,"hint":"Ensure that no rows proposed for insertion within the same command have duplicate constrained values.","message":"ON CONFLICT DO UPDATE command cannot affect row a second time"}
    I have a code with onConflict of two columns so it doesnt insert duplicate and just updates it.
    Copy code
    js
     const { error: insertion_error } = await supabase_connect
          .from('Contact')
          .upsert(data, { onConflict: 'user_id,phonenumber' });
    • 1
    • 2
  • Supabase and Zustand doesn't trigger useEffect
    p

    Pr. rootKitty

    03/11/2023, 12:02 PM
    Hi guys, Im having a hard time trying to update a component with useEffect according to a user state stored in zustand Im using supabase and Im pretty new to using both of these, here's my code :
    Copy code
    ts
    // Watchlist page, having all the favorites shows of the user (user.saved_shows)
    const Watchlist = () => {
      const user = useAuthStore((state) => state.user)
      const [loaded, setLoaded] = useState(false)
    
      useEffect(() => {
        setLoaded(true)
        console.log('User updated in component')
      }, [user])
    
      return (
        <div className={styles.container}>
          <Sidebar />
          {loaded && (
            <div className={styles.watchlistCardsContainer}>
              {user?.saved_shows?.map((show) => (
                <SavedShowCard key={show} showId={show} userId={user.id} />
              ))}
            </div>
          )}
        </div>
      )
    }
    
    export default Watchlist
    Copy code
    ts
    // User store
    import { persist } from 'zustand/middleware'
    import { supabase } from '@/utils/supabase'
    import type { User } from '@/types/user.interface'
    
    interface AuthStore {
      user: User | null
      setUser: (user: User | null) => void
      signUp: (name: string, email: string, password: string) => Promise<void>
      signIn: (email: string, password: string) => Promise<void>
      signOut: () => Promise<void>
      isLoaded: boolean
      setIsLoaded: (isLoaded: boolean) => void
    }
    
    export const useAuthStore = create<AuthStore>()(
      persist(
        (set, get) => ({
          user: null,
          setUser: (user) => {
            set(() => ({ user }))
            console.log('User updated in store')
            localStorage.setItem('user', JSON.stringify(user)) // Save user to local storage
          },
    ...
    What is confusing me is that the console log User updated in store gets triggered, while the console log User updated in component doesn't what am I missing ? 😮
    b
    • 2
    • 2
  • Fetch many-to-many relations for self-referencing table
    m

    mahaveer

    03/11/2023, 12:48 PM
    Hi folks, I have the following schema. An account is either a
    USER
    account or an
    ORGANIZATION
    account and
    members
    is the mapping table between different account types.
    Copy code
    sql
    create type "public"."account_type" as enum ('ORGANIZATION', 'USER');
    
    create table "public"."accounts" (
        "id" uuid not null default uuid_generate_v4(),
        "created_at" timestamp with time zone default now(),    
        "slug" text not null,
        "type" account_type
    );
    
    create table "public"."members" (
        "id" uuid not null default uuid_generate_v4(),
        "created_at" timestamp with time zone not null default now(),
        "user_id" uuid not null references accounts(id),
        "organization_id" uuid not null references accounts(id),
    );
    
    CREATE OR REPLACE FUNCTION public.check_members_constraint() RETURNS trigger LANGUAGE plpgsql AS 
    $function$BEGIN
        IF (SELECT type FROM accounts WHERE id = NEW.user_id) <> 'USER' THEN
            RAISE EXCEPTION 'user_id must reference an account with type = "USER"';
        END IF;
        
        IF (SELECT type FROM accounts WHERE id = NEW.organization_id) <> 'ORGANIZATION' THEN
            RAISE EXCEPTION 'org_id must reference an account with type = "ORGANIZATION"';
        END IF;
    
        RETURN NEW;
    END;$function$;
    
    CREATE TRIGGER members_constraint_trigger BEFORE INSERT ON public.members FOR EACH ROW EXECUTE FUNCTION check_members_constraint();
    When i run the following GQL query, how can i specify which column should be used to resolve the relation?
    Copy code
    gql
    {
      accounts: accountsCollection {
        edges {
          node {
            slug # <--- lets say this is account X
            members: membersCollection {
              edges {
                node {
                  user_id
                  organization_id
                  accounts {
                    slug # <--- this is referring to the same account X how to tell supabase to resolve account with `organization_id` instead
                  }       
                }
              }
            }
          }
        }
      }
    }
  • Using one projects data in another project?
    r

    redwookie

    03/11/2023, 1:13 PM
    Is it possible to data from one project in another project? Like having a database with messages and use them in another project?
    g
    • 2
    • 3
  • Upload a photo
    d

    Dean1

    03/11/2023, 1:19 PM
    I have a form in which I specify data and it gets into the database, how can I make sure that the photo that I insert gets into the database?
  • No password reset email?
    r

    Raj Bennin

    03/11/2023, 1:38 PM
    Tried getting a password reset to no avail as I'm not receiving any email. Attempting to sign up again proves that the email already exists.
    g
    • 2
    • 12
  • dashboard hasn't connected within 2 minutes
    m

    mogoatlhe

    03/11/2023, 2:26 PM
    hello, I've just created a supabase account and new project. After this I got redirected to the
    setting up project
    page which has been loading for over 40 minutes. I tried refreshing the page a few times but that didn't help. Can someone please help.
    g
    • 2
    • 4
  • Realtime Audio Broadcasting
    b

    Benanna19

    03/11/2023, 2:52 PM
    Hello supabase friends. I've been thinking about this for a while, probably too long, and was wondering how one would go about sharing/broadcasting audio in realtime? Im not quite sure if broadcasting is the best way or if it's best to sync audio on presence events. But the idea is that someone has a profile and they are playing music. A visitor can see that person is playing and 'listen in' to their song. In my mind this would be done on presence because if someone joins in, then the presence state would sync and then they would receive that audio player value on their end. In react I have been thinking about this with useRef and a player time that would be sent and it would start the visitors player at that same time. Just wondering if anyone has played with this type of thing with realtime yet. The idea is to do in React what Chris McCord's Livebeats does in Elixir.
    u
    • 2
    • 1
  • one to many relationship not working.
    s

    shawns2759

    03/11/2023, 3:24 PM
    I want to have a column called resources that is an array of resourceIds that are referenced from another table? How can I do this on the ui?
    g
    g
    • 3
    • 3
  • data stream from edge function
    e

    EK

    03/11/2023, 3:24 PM
    Copy code
    if (isStreaming) {
          eventSource = new EventSourcePolyfill(
            'https://123123xpsdtmtk.functions.supabase.co/stream',
            {
              headers: {
                'Access-Control-Allow-Origin': '*',
                'Access-Control-Allow-Credentials': 'true',
                Authorization: 'Bearer ' + token,
                'Content-Type': 'text/event-stream',
                'Cache-Control': 'no-cache',
                Connection: 'keep-alive',
              },
            }
          )
    I am trying to use data stream from a edge function, but I could not get it to work. It always threw a cors error. I tried the regular way of ``supabase.functions.invoke('stream')``' but it return data in a big chuck.
    • 1
    • 2
  • Daily quota of built-in emails?
    n

    nateland

    03/11/2023, 3:57 PM
    Is there a daily quota to emails I can send using the built-in email server?
    g
    f
    • 3
    • 35
  • Flutter Reset Password workflow
    n

    nname

    03/11/2023, 3:59 PM
    Does anyone have a working example of the reset password workflow? I can't locate what seems to be the last step. Deep linking is correct and I get to the reset route, but deep links seem to stop parsing at the #. I'm still able to get the jwt and refresh tokens to the page but can't appear to get them into the Supabase.instance.client.
    • 1
    • 1
  • Can't get .join() to work with the javascript SDK
    c

    Caleb

    03/11/2023, 6:16 PM
    Hi all, I'm new to Supabase and sql, and I'm trying to get a .join function to work in a Node.js backend. Whenever I try to call join, I get the error "Property 'join' does not exist on type 'PostgrestQueryBuilder'" What am I missing here? I translated this javascript directly from this SQL query, which works fine in the SQL editor.
    g
    • 2
    • 2
  • error upload image in supabase
    d

    Dean1

    03/11/2023, 7:08 PM
    I have form <input id="image" type="file" class="form-control" aria-label="file example" required /> and i want upload photo in base const avatarFile = document.getElementById("image"); const { data, error } = database.storage .from("countimage") .upload("countimage", avatarFile); but my browser give me error https://lkrywbpogaydvgrohlje.supabase.co/storage/v1/object/countimage/ 400 --------- const avatarFile = event.target.files[0]; const { data, error } = await database.storage .from("countservice") .upload("img/avatar1.png", avatarFile, { cacheControl: "3600", upsert: false, }); error App.js:51 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'target') at HTMLButtonElement. (App.js:51:32) and supabase-js:7 POST https://lkrywbpogaydvgrohlje.supabase.co/storage/v1/object/countservice/img 400 say me pls, how i can upload photo
  • Do RLS policies check the JWT or Sessions?
    e

    Eric

    03/11/2023, 7:46 PM
    TL;DR - I am able to make API requests to a table protected by authenticated RLS after logout. I have a table with RLS enabled with the following policy applied to `authenticated`:
    Copy code
    BEGIN;
      ALTER POLICY "Places - Only authenticated users" ON "public"."places" USING (true);
    COMMIT;
    With no
    Bearer
    token on my initial requests, api requests to this table correctly fail. Then, I log in and get a valid user response (and can see a session in the
    auth.sessions
    table). My request to the table now succeeds correctly. However when I log out via the api (and see the row removed from the sessions table), I am still able to make API requests to the table. If I wait the TTL for the JWT, it expires as expected and API requests to the table fail properly. My question: - does the
    authenticated
    policy check the JWT on the request to see if the user is authenticated or does it check the
    auth.sessions
    table? I would expect a non-expired JWT to still fail if there is no active session. - is there a way to enable RLS to check if the user in the JWT has an active session? does the authid helper method here https://supabase.com/docs/guides/auth/row-level-security#authuid check the JWT or the session user?
    g
    • 2
    • 4
  • storage
    d

    Dean1

    03/11/2023, 8:52 PM
    let file = document.getElementById("image"); const { data, error } = await database.storage .from("images") .upload("public" + file?.name, file);
    g
    • 2
    • 15
  • Trying fetch an image from url and upload it to supabase storage
    k

    killerthief

    03/11/2023, 9:00 PM
    Copy code
    const req  = await axios.get("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQo2zi7aWGrKd8eTtROEbeG4noyYyEicLaqpMOmqXXN&s",{responseType:"arraybuffer"});
          console.log(await req);
          const imgBlob = new Blob([req.data],{"type": "image/jpeg"});
          const imgUrl = URL.createObjectURL(imgBlob);
          const Imagefile = new File([imgUrl],"imageGenerator.png",{type:"image/png"});
          const d = new Date();
          const time = d.getTime();
          console.log(imgBlob);
          console.log(Imagefile);
          const {data,error} = await supabase.storage.from('images').upload(`${time}`,Imagefile,{cacheControl:'3600',upsert: false})
          if(error === null){
            const{data,error} = await  supabase.storage.from('images').createSignedUrl(`${time}`,31563000)
            console.log("Inner data of the signed url",data);
            if(error === null){
                const txnHashtoken = await (window as any).martian.createToken(collectionName,  `${text}`, "keep it simple", 1,data, maxsupply)
                console.log("Printing the hash token",txnHashtoken);
            }
            else{
              console.log("Cannot create the signature URL ");
            }
          }
          else{
            console.log("Cannot upload the image");
          }
    js Above is the code . I have given an example like I am tryign to fetch an image from the url and store it in the supabase storage haven't been quite successful in it . Any clue anyone ?
    g
    • 2
    • 4
1...163164165...230Latest