https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Is it possible to chain policy 'using' conditions?
    r

    Ramdinpuia29

    12/20/2022, 11:48 AM
    Copy code
    CREATE POLICY user_update_own_scores ON my_scores
        FOR ALL
        USING (auth.uid() = user_id);
    into something like
    Copy code
    CREATE POLICY user_update_own_scores ON my_scores
        FOR ALL
        USING (auth.uid() = user_id OR email='email@example.com');
    o
    g
    • 3
    • 6
  • how to access the files in private bucket
    p

    Pum Pum

    12/20/2022, 11:56 AM
    So I had a public bucket in which I had a folder named the same as the
    userid
    and inside that I was storing files. after that I made that bucket private and now I can't access the file using the CDN what I want is to let the owner access their file and no one else how can I do that in a private bucket?
    o
    • 2
    • 1
  • Creating default-data on signup
    s

    SM0RT

    12/20/2022, 12:04 PM
    I am looking to insert some default-data into a table whenever a new user is created. For this, I would create a trigger on my profiles table, where a new row is created when a new user signs up. The profile-table, which gets an new entry each time a user is created looks like this:
    Copy code
    sql
    "id" (uuid, PK)
    "username" (text)
    "language_code" (char(2))
    Imagine I have a database of cars with a table called "car", with the following columns
    Copy code
    sql
    "id" (uuid, PK, default: uuid_generate_v4()), 
    "user_id" (uuid, FK to the user this car belongs to, required, no default)
    "brand_name" (varchar, required, no default)
    "model_name" (text, required, no default)
    "created_at" (timestampz, default: now())
    "isDefaultEN" (bool, default: false)
    "isDefaultDE" (bool, default: false)
    To achieve this, I would create a trigger like so:
    Copy code
    sql
    -- inserts a row into public.car
    create function public.handle_new_profile()
    returns trigger
    language plpgsql
    security definer set search_path = public
    as $$
    begin
      
      [FOLLOWING CODE GOES HERE]
    
    end;
    $$;
    
    -- trigger the function every time a user is created
    create trigger on_profile_created
      after insert on public.profile
      for each row execute procedure public.handle_new_profile();
    o
    s
    g
    • 4
    • 13
  • 'supabaseauth-helpers-nextjs' gives SyntaxError Unexpected token 'export'
    s

    simonbarker

    12/20/2022, 12:13 PM
    Just adding '@supabase/auth-helpers-nextjs' so I can access user session in an API Route and this line:
    Copy code
    import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'
    Causes this message to appear in the terminal:
    Copy code
    SyntaxError: Unexpected token 'export'
    Without that import the endpoint is fine, From my package.json:
    Copy code
    "next": "12.0.7",
    "@supabase/supabase-js": "^2.2.1",
    "@supabase/auth-helpers-nextjs": "^0.5.2",
    "@supabase/auth-helpers-react": "^0.3.1",
    All the client side auth seems to be working fine (I had to upgrade
    @supabase/supabase-js
    from 1.3.5 to 2.2.1) Any ideas on how to fix this would be very appreciated. Thanks
    • 1
    • 1
  • All Tables's elements must be unique error
    c

    chinds

    12/20/2022, 12:58 PM
    Hi, Trying to create a new table and import CSV data, when hitting save I get the following error All Tables's elements must be unique I cant figure out what the issue is.
    g
    m
    +2
    • 5
    • 25
  • I can't remove the row
    u

    ν—ˆλ„μ›

    12/20/2022, 1:56 PM
    I remove a row but the row is just not removing
    g
    j
    • 3
    • 8
  • onConflict upsert shenanigans
    g

    Guy Rozen

    12/20/2022, 2:03 PM
    Placing a single column name in an upsert supabase query results in the intended expected behavior. However, adding more than one with a splitting comma between said column names results in an error (for example, { onConflict: "name, display_name" }): Error: there is no unique or exclusion constraint matching the ON CONFLICT specification. Is there something I may be missing here? Maybe wrong syntax for multipile columns per onConflict? Also, is it possible to list a large amount of column names for specific upsert queries?
    g
    • 2
    • 15
  • Email Service
    z

    zeedee

    12/20/2022, 4:26 PM
    Is there a built in method to send emails from supabase? Just asking if there is any built-in functions, or a way to use the auth
    email()
    function for custom emails. Thanks in advance.
    v
    s
    a
    • 4
    • 7
  • Edge function response error
    c

    Creix

    12/20/2022, 5:05 PM
    Hi, i'm tryng to understand how error messages works in edge functions, because every time i return a response with code 400, the error message is always "Edge Function returned a non-2xx status-code" instead of the error message i have written in the function. This is my setup to throw and catch error in my function
    s
    d
    • 3
    • 15
  • Get current user in public function
    m

    mrmikardo

    12/20/2022, 5:09 PM
    I have a trigger function that I'd like to run after insert into a given table;
    Copy code
    begin
      insert into public.example_table (user_id, access_token_id)
      values (new.user_id, new.id);
    end;
    The only issue is,
    new
    doesn't contain a reference to
    user_id
    . Is there a function or something I can use to grab a reference to the user attempting the insert?
    g
    • 2
    • 2
  • Session Timeout
    v

    vipultanwar

    12/20/2022, 5:31 PM
    How to set session timeout after 1 hours ?
    g
    • 2
    • 6
  • Using Supabase Auth on customer's domain?
    n

    novon

    12/20/2022, 6:06 PM
    I'm wondering if it's possible to map a customer's domain like
    help.company.com
    to our assigned subdomain like
    company.ourapp.com
    and still have Supabase Auth manage authentication on both?
  • Table says null but is not nulll
    u

    (FOX)

    12/20/2022, 6:20 PM
    Hi im new to supabase db and I try supabase db. here is first my question I have table called archive in supa base you see the photo when I call archive from vanilla ts it says null. but data have you see.
    g
    • 2
    • 14
  • How to disable email confirmation at signup?
    h

    hqn

    12/20/2022, 6:30 PM
    I've seen reference to the setting of email confirmation and being able to disable it, but under my project's settings I can't seem to find the toggle anywhere. In the docs, https://supabase.com/docs/reference/javascript/auth-signup has "By default, the user needs to verify their email address before logging in. To turn this off, disable Confirm email in your project." and links to https://app.supabase.com/project/_/auth/settings which redirects to /auth/users. This https://github.com/supabase/supabase/issues/5113 makes it look like it used to be next to custom smtp but I don't see it under https://app.supabase.com/project/_/settings/auth either. Lastly I see a "enable_confirmations" flag in the supabase/config.toml file, which I've edited to false, but it doesn't seem to have an effect (and I don't see anything in the CLI documentation about pushing settings updates). How can I disable email confirmations, or has that ability been removed? I need it for anonymous login -- it's the suggested workaround at https://github.com/supabase/gotrue/issues/68. Much thanks for any help!
    g
    • 2
    • 6
  • Edge Functions not connecting webhooks
    z

    zeedee

    12/20/2022, 6:48 PM
    Is there auth requirements to triggering an edge function with a webhook? My service (samsara) pings correctly to a test like "webhook.site", but my supabase client doesn't register webhook pings. Attachment one shows the configured settings My function is just the default hello_world
    Copy code
    js
     // functions/samsara_hooks/index.ts
    
    import { serve } from "https://deno.land/std@0.131.0/http/server.ts"
    
    console.log("Hello from Functions!")
    
    serve(async (req) => {
      const { name } = await req.json()
      const data = {
        message: `Hello ${name}!`,
      }
    
      return new Response(
        JSON.stringify(data),
        { headers: { "Content-Type": "application/json" } },
      )
    })
    Is there a chance that Supabase is blocking it?
    g
    • 2
    • 6
  • Query Differences in JS
    a

    AliCodes!

    12/20/2022, 8:30 PM
    No errors this time, but any reason why ```sql SELECT created_at, sender, receiver, amount, message FROM transactions WHERE sender='+45 60 55 04 82' LIMIT 10; ```returns at least a row as a result, but ```js const res = await supabase.from("transactions") .select("created_at, sender, receiver, amount, message") .eq("sender", id) .limit(10); ```returns 0 rows? The queries look identical, as far as I can tell...
    g
    s
    • 3
    • 5
  • Issue with RLS for authenticated users
    n

    NicoY

    12/20/2022, 8:59 PM
    Hi, I'm actually working on an article website and I try to retrieve these articles only when a user is logged-in. Working with RLS, all of my articles are returned when I let access to all users or 'anon' users but once I try with 'authenticated' (while being authenticated), nothing is returned. I use auth-helpers πŸ™‚ I can see logs of sign in supabase when I login tho. Thanks πŸ™‚
    s
    • 2
    • 19
  • RLS policy not working as expected
    r

    Ron W

    12/20/2022, 9:22 PM
    Hi all! I added a policy called
    "Enable insert for authenticated users only"
    using the available template. However, even after enabling this policy I can still insert to the table using the
    anon
    role, without having to log in as a user with the
    authenticated
    role. This is undesirable behaviour. A screenshot of the policy window is attached. The only other policy enabled for the table is the
    Enable read access for all users
    policy, which was also generated from the template without modification.
    s
    g
    l
    • 4
    • 11
  • webhook request headers
    z

    zeedee

    12/20/2022, 10:11 PM
    Looking for request headers in an edge function, how do I access these. I've been diving through the deno docs for hours, but I have not been successful. Heres the headers I need to access, can someon help me out here?
    g
    • 2
    • 1
  • Supabase storage JWT error
    e

    Emruur

    12/20/2022, 10:25 PM
    Hi i am using nuxt3 and its supabase module with supabase. I get en error "JWT malformed" from the storage api when getting the auth session with supabase.auth.getSesssion() . I don't get the error when getting the session with the useSupabaseUser() function which is included in the nuxt-supabase module. Is the problem in using both methods? I am having a very difficult time with the auth service of supabase. By the way i disableded all security on the storage bucket for testing purposes. There is no rls or anything. Thank for any support.
  • Two responses doesn't work?
    z

    zeedee

    12/20/2022, 10:47 PM
    Deno Edge functions
    Copy code
    js
    serve(async (req: Request) => {
      const secret = decode(Deno.env.get('SAMSARA_WEBHOOK_SECRET'))
      console.log("secret: " + secret)
      const request = await req.json()
    
      if (true) {
        return New Response({
          status: 404
        })
      }
    
      )
      return new Response(
        JSON.stringify(),
        { headers: { "Content-Type": "application/json" } },
      )
    })
    Copy code
    error: Uncaught (in promise) Error: The module's source code could not be parsed: Expected ';', got 'Response' at file:///src/index.ts:194:16
          const ret = new Error(getStringFromWasm0(arg0, arg1));
                      ^
        at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:312:19)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:79439)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1388039)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1862894)
        at __wbg_adapter_18 (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:146:6)
        at real (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:130:14)
    every variation of this fails to compile. Can someone help me out here please?
    g
    • 2
    • 2
  • When creating a JWT I'm also able to sign in some extra data.Is there a way for us to add some data
    n

    nav

    12/20/2022, 11:15 PM
    When creating a JWT I'm also able to sign in some extra data. Is there a way for us to add some data to the JWT generated by Supabase. We're trying to add signed roles to the JWT.
    g
    • 2
    • 1
  • Why is the data and error fields empty here? The registration to Supabase was successful.
    r

    rayctf

    12/20/2022, 11:33 PM
    Nothing gets logged to the console? I would expect some metadata right?
    g
    • 2
    • 1
  • Is the service down?
    e

    emileon

    12/21/2022, 3:37 AM
    I'm getting an error: ERR_CONNECTION_TIMED_OUT for all my queries, everything was working correctly until like 15m ago. I wonder if there's a service down or something? Are you experiencing issues?
    l
    d
    • 3
    • 5
  • How to satisfy TypeScript on an update and select query
    v

    Vik

    12/21/2022, 4:15 AM
    I'm working on a giant function that handles uploading photos, updating your public profile, and then returning your updated profile. But I'm blocked on how to properly type out this function. I have a SupabaseUserProfile type that matches my schema and I'm using it in other places. But in this instance I had to alias the data value since I'm using it in this scope already. Screen and text:
    Copy code
    // Get the public URL
            const { data } = await supabase.storage
              .from('avatars')
              .getPublicUrl(filePath);
    
            // Update the users public profile with the new avatar URL
            const { data: updatedUserProfile, error: updatedUserProfileError } =
              await supabase
                .from('profiles')
                .update({ avatar_url: data.publicUrl })
                .eq('id', userID)
                .select();
    
            if (updatedUserProfileError) {
              throw Error('User profile was not updated with new avatar URL.');
            }
    
            setUserProfile(updatedUserProfile);
    n
    • 2
    • 16
  • Form Validation
    f

    frozenPresence

    12/21/2022, 4:59 AM
    What is the best way to handle form validation when doing inserts from the client? For example, the length of fields, that an email address is a valid format, or that a value is If I have a form, I need to ensure that it is filled out properly before I store the data. Client side validation can be bypassed so I need something at the database or server level. Is the easiest way to do validation with a check constraint? It seems like that would be hard to keep in sync with the frontend? Or can I do this easily with edge functions? Doesn't that defeat the purpose of client side inserts / Postgrest?
    u
    • 2
    • 1
  • Edge Functions vs Vercel
    f

    frozenPresence

    12/21/2022, 5:05 AM
    If I host a website with Vercel, what is the best use for Supabase edge functions, Vercel's serverless functions, and Vercel's edge functions?
    n
    • 2
    • 1
  • Storage file versioning
    f

    frozenPresence

    12/21/2022, 5:12 AM
    Is there a way to version files that are saved in storage? To keep older versions around after an update? Similar to S3 versioning?
  • Supabase bucket template policy is failing
    v

    Vik

    12/21/2022, 5:18 AM
    I'm using the allow users with their ID as the folder name access template for storage policies in my public avatars bucket. I selected the INSERT, DELETE, UPDATE and for SELECT I left that as only authenticated users. If I open up this policy to all authenticated users everything works just fine. Curious on why the template would not be working given it's from Supabase. The file location is avatars/UID/avatar.
    Copy code
    const filePath = `${userID}/avatar`;
    
            // Append the data to the formData class
            formData.append('file', imageData);
    
            // Upload or replace existing users avatar
            let { error } = await supabase.storage
              .from('avatars')
              .upload(filePath, formData, {
                upsert: true,
              });
    
            // Handle any errors that may occurr
            if (error) {
              throw Error('Image upload failed.');
            }
    g
    • 2
    • 18
  • list all files in storage bucket
    j

    jar

    12/21/2022, 5:37 AM
    I simply want to list storate photos...of course simple things dont work. I have 170 items and doing
    Copy code
    const { data, error } = await supabase
      .storage
      .from('avatars')
      .list()
    returns 100. How can I simply get the other 70... This is example from docs. I have no folders and can't find a variation that works
    Copy code
    const { data, error } = await supabase
      .storage
      .from('avatars')
      .list('folder', {
        limit: 100,
        offset: 0,
        sortBy: { column: 'name', order: 'asc' },
      })
    Why cant this work. I have no sub folder
    Copy code
    const { data, error } = await supabase
      .storage
      .from('avatars')
      .list({
        limit: 100,
        offset: 0,
        sortBy: { column: 'name', order: 'asc' },
      })
    g
    • 2
    • 2
1...747576...230Latest