https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Did supabase client has cold start problem?
    j

    Jokcy

    04/17/2023, 1:34 PM
    I just notic supabase use serverless api (postgrest), so is that mean we also need to face the cold start problem? If it does, how long it will take?
    g
    • 2
    • 2
  • Can I add column level security?
    l

    Lukas V

    04/17/2023, 1:51 PM
    Hello, I have a table
    creators
    and I have a column
    relevance_score
    , I don't want creators to be able to edit their relevance score, themselves, so is there a way to create a RLS policy that prevents users to update that column themselves?
    g
    • 2
    • 8
  • getSession with getServerSideProps in Next.js is returning null
    m

    mikel

    04/17/2023, 3:25 PM
    Hey there, I'm currently trying to get the current user session with the getServerSideProps in next.js and typescript, and I always get a null response when I try to retrieve the user's session. But, if I try to get the current session on the client side in useEffect with supabaseClient.auth.getSession(), it works fine. I need to retrieve the user's data inside the getServerSideProps therefore I need to get the session within it. Please tell me what I'm missing out. Thanks!

    https://cdn.discordapp.com/attachments/1097543368264908900/1097543368508198922/7bb56946-3e7c-45d9-8147-366f7bdb2c40.png▾

    https://cdn.discordapp.com/attachments/1097543368264908900/1097543368801787914/6868ec6a-1c67-4871-8fb4-fefe65559205.png▾

    n
    a
    +2
    • 5
    • 21
  • What is the best way for handing image(s) using PostgreSQL + Supabase storage
    n

    netdesignr

    04/17/2023, 3:39 PM
    Hi lovely community, I'm working on a platform that allows users create a variety of listing types. One of the type requires allowing the users to add picture(s). Has anyone got any documentation or example around how Supabase storage and PostgreSQL can take advantage of that? The idea is that the users can add multiple listings and it has to make sure that the images are only showing for the relevant listing. Because the platform needs to allow the users to add the images upon the creation of the listing there's no unique ID that can be used on the image names to create that distinction. Any thoughts? Thank you!
    g
    • 2
    • 4
  • Static confirmation OTP + Phone number for app store review
    d

    doorknob88

    04/17/2023, 5:40 PM
    I'm trying to setup a static OTP and test phone number to use for app store reviews. I followed this: https://github.com/orgs/supabase/discussions/5358#discussion-3860072
    Copy code
    CREATE FUNCTION test_credentials()
    RETURNS TRIGGER
    AS $$
    BEGIN
        IF (NEW.phone = ANY(array['<test-phone1>', '<test-phone2>'])) THEN
            NEW.confirmation_token := '123456';
        END IF;
        RETURN NEW;
    END;
    $$ LANGUAGE plpgsql;
    
    CREATE TRIGGER test_credentials BEFORE INSERT OR UPDATE ON auth.users FOR EACH ROW EXECUTE PROCEDURE test_credentials();
    to setup a trigger to setup an override for a particular phone number. it worked on my local self hosted setup but when i set it up against https://app.supabase.com/ , it doesn't seem to work. I checked the table value being altered and noticed that the confirmation tokens in the users table is being hashed/encoded to some string so that the confirmation token value isn't exposed (which isn't the case for when my function overrides it.) I'm wondering where I can find what that hash function is so that my overridden confirmation token can be used.
  • React Query and TypeScript
    m

    marcusdavanco

    04/17/2023, 5:40 PM
    I'm working on this Next 13 project that also uses React Query, and while creating the custom hook to handle the file uploads, I got a little confused about the types that should be used on the arguments for the functions that are used on the onSuccess/onError properties of the useMutation function from React Query., here's what I have:
    Copy code
    ts
    async function attachProjectFiles(project: ProjectFormValues, file: File) {
      const attachments = await supabase.storage
        .from("attachments")
        .upload(`${project.name}/${file.name}`, file, {
          cacheControl: "3600",
          upsert: false,
        });
    
      return attachments;
    }
    In the attachProjectFiles, the response from the request that is sent to the storage is typed like this:
    Copy code
    ts
    {
        data: {
            path: string;
        };
        error: null;
    } | {
        data: null;
        error: StorageError;
    }
    Considering that we have to use those types to destructure the error at least on the function that is passed to the onError property, what type should be used? I've considered creating an interface that corresponded to the type that mentioned above, but I didn't found the StorageError type exported from @supabase/supabase-js, any recommendations on what should be used? Here's the hook I have right now:
    Copy code
    ts
    export function useAttachProjectFiles(project: ProjectFormValues, file: File) {
      const queryClient = useQueryClient();
    
      return useMutation({
        mutationFn: () => attachProjectFiles(project, file),
        onSuccess: async () => {
          await queryClient.invalidateQueries(["attachments"]);
        },
        onError: ({ error }: { error: unknown }  /* TODO: Replace with proper typing */) => { 
          console.error((error as Error)?.message);
        },
      });
    }
    Thanks in advance
    • 1
    • 1
  • SQL query to enable realtime sync for a table
    y

    Yuu

    04/17/2023, 5:53 PM
    How do I enable this option with SQL query (that I can put in a migration)

    https://cdn.discordapp.com/attachments/1097580601797783664/1097580601952968876/image.png▾

    g
    • 2
    • 1
  • Custom hook using React Query and Supabase
    r

    Rikka

    04/17/2023, 6:15 PM
    A custom hook I write using react query combine supabase. Are you have the better solution to write?

    https://cdn.discordapp.com/attachments/1097586093106397297/1097586093672636456/image.png▾

  • Error dumping db
    p

    preef

    04/17/2023, 6:25 PM
    Following the advice here (https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects), I'm running the following script
    Copy code
    supabase db dump --db-url "$DB_URL_PROD" -f dumps/roles.sql --role-only &&\
    supabase db dump --db-url "$DB_URL_PROD" -f dumps/schema.sql  &&\
    supabase db dump --db-url "$DB_URL_PROD" -f dumps/data.sql --data-only
    The first two invocations of
    pg_dump
    run fine, but the
    data-only
    invocation fails with the following error:
    Copy code
    pg_dump: error: query failed: ERROR:  permission denied for sequence hooks_id_seq
    pg_dump: detail: Query was: SELECT last_value, is_called FROM "supabase_functions"."hooks_id_seq"
    Any ideas for fixing this?
    • 1
    • 1
  • RPC automatically casting string to uuid for a function with a text argument
    i

    imagio

    04/17/2023, 7:56 PM
    I've got a postgres function that takes a string
    Copy code
    CREATE OR REPLACE FUNCTION public.update_fcm_key
        (new_key TEXT) RETURNS bool
        LANGUAGE plpgsql
        SECURITY DEFINER AS
    $$
    .....
    but when I call it from the supabase client I end up with
    No operator matches the given name and argument types. You might need to add explicit type casts.","message":"operator does not exist: text = uuid"
    It seems that the Supabase client is detecting any string with dashes in it as a UUID and blindly casting it. Is this just a known bug? Is there a way to add an explicit cast from the
    supabase.rpc
    client?
    g
    • 2
    • 2
  • Adding Roles does not work in JWT
    r

    Rosibert

    04/17/2023, 8:02 PM
    Hello there! I tried to add roles to my project but the JWT recieved does not contain the role created.
    Copy code
    js
    const { error } = await supabase.auth.signUp({
                    email,
                    password,
                    options: {
                        roles:['customer']
                    }
                });
    Is there an easy way to do so?
    g
    • 2
    • 23
  • how to store a password if i use 0auth?
    a

    Ammar Almuain

    04/17/2023, 9:21 PM
    i mean there is no password created when useing 0auth how to store the user in the database? the problem here maybe the user imm go for login via providers which supabase allow that but no password return so that if person maybe want to login back using email or even though what will be the senistive data
    • 1
    • 1
  • 404 error on /storage/v3/upload/resumable endpoint
    r

    Ryan [untitled]

    04/17/2023, 9:44 PM
    Currently I see
    Uncaught (in promise) Error: tus: unexpected response while creating upload, originated from request (method: POST
    when I attempt to post an upload to the endpoint outlined in https://supabase.com/blog/storage-v3-resumable-uploads
    g
    s
    • 3
    • 6
  • Call a postgress function error: 'access denied' with custom claims on the client side
    t

    Tiago

    04/17/2023, 9:45 PM
    Hi there, I have set up my supabase app with the
    custom claims
    (https://github.com/supabase-community/supabase-custom-claims) and everything works fine on the dashboard, (1) I can
    get_claims
    , (2)
    set_claims
    . Not a problem doing that from the sql editor on supabase dashboard. However, once I try to call a postgress function on the client side I always get error:`access denied`. Example of my function:
    Copy code
    async function checkProfileClaims() {
        try {
          const updates = {
            uid: userData.id,
            // claim: "userrole",
            // value: "Broker",
          };
          let { error, data } = await supabase?.rpc('get_claims', {...updates});
          if (error) throw error;
          console.log({ data, updates });
        } catch (error) {
          alert(JSON.stringify(error, null, 2));
          console.log({ error, updates });
        }
      }
    Thank you for the help.
    g
    • 2
    • 26
  • Configure CORS from dashboard?
    r

    Rocket

    04/17/2023, 10:28 PM
    Is there a way to configure CORS for my gql server from the Supabase dashboard? Haven't found it so far if there is one and I feel quite blind.
    g
    • 2
    • 1
  • Typescript help
    x

    xdcx18

    04/17/2023, 10:42 PM
    So I am trying to use the property types and I am having trouble because when destructuring the data from DB I can't use the type that I want. It's frustrating because every time I try to assign the type even in different places it says "Type '{ [x: string]: any; }' is missing the following properties from type..." it keeps defaulting to the type from just the response, which is not what I want.I even tried setting the type after I pass it as props but still the same thing 😕

    https://cdn.discordapp.com/attachments/1097653307293581474/1097653307541049404/Screenshot_2023-04-17_at_5.37.29_PM.png▾

    n
    • 2
    • 2
  • Contains filters combined by OR
    s

    squallsama

    04/17/2023, 10:43 PM
    I'm trying to build query like:
    Copy code
    supabaseClient
            .from('user_profiles')
            .select<List<Map<String, dynamic>>>() .or("nick_name.contains.$searchPhrase,name.contains.$searchPhrase")
    But got following exception:
    Copy code
    PostgrestException(message: "failed to parse logic tree ((nick_name.contains.spar,name.contains.spar))" (line 1, column 23), code: PGRST100, details: unknown single value operator contains, hint: null)
    Any suggestions about proper syntax or docs ? All examples related to
    or
    uses
    eq
    as filters
    g
    • 2
    • 9
  • Self Hosted supabase postgres connection string for Prisma
    e

    ekansh005

    04/17/2023, 11:00 PM
    Hi, I am new to self hosting and just self hosted supabase using docker compose. My node.js app is running in a separate docker network than supabase (created by default) on the same ubuntu server VM. Now, I am stuck at the connection string for prisma. I have tried
    DATABASE_URL="postgresql://postgres:my-secret-pwd@localhost:5432/postgres?connection_limit=40&pool_timeout=60"
    but it is not connecting to supabase postgres and failing with `Error: P1001: Can't reach database server at `localhost`:`5432` Please make sure your database server is running at `localhost`:`5432`.` Can someone please help with this one?
    t
    v
    n
    • 4
    • 5
  • Typescript with Supabase and Next. Property `ok` does not exit on Type.
    e

    esparkman

    04/17/2023, 11:02 PM
    I'm attempting to use Typescript with Supabase and Next 13.3. I'm seeing this error
    Property 'ok' does not exist on type PostgresSingleResponse
    I'm at a loss as to how to get the Types pulled in for this. I'm also not able to pull back data.
    n
    • 2
    • 10
  • Upsert prevented by RLS.
    m

    mansedan

    04/17/2023, 11:07 PM
    Hey all, We are having an issue w/ our batch upsert. Our SELECT and UPDATE policies are using the same using/checks ( see attached ). The select works perfectly fine, but we get the following error on upsert: > new row violates row-level security for table "notifications" Here is how we are making the request (simplified here):
    Copy code
    js
    const supabaseClient = createServerSupabaseClient({ req, res })
    const { data: notifications, error } = await supabaseClient
          .from('notifications')
          .select('*')
          .order('notification_date', { ascending: false })
    
    // handful of lines between requests that shouldnt be relevant. and then:
    const readNotifications = [...notifications].map(({ id }) => ({ id, read: 1 }));
    const { data: readNotifications, error: readNotificationsError } = await supabaseClient.from('notifications').upsert([...readNotifications], { onConflict: 'id' })

    https://cdn.discordapp.com/attachments/1097659723429462128/1097659723555283024/image.png▾

    https://cdn.discordapp.com/attachments/1097659723429462128/1097659723823714344/image.png▾

    g
    • 2
    • 18
  • New row violates row-level security policy for table
    a

    adt2

    04/17/2023, 11:14 PM
    I'm a new user, so I'm sure I'm missing something simple, but I've spent hours trying to figure this out and so far, no dice. I've got a simple table "costcodes" with a few columns: id, name, note, user_id. I've created sign up / sign in flow in Flutter for my front end, and they seem to be working (I get the confirm email message at sign up, and when I look at the users tab, I appear as a user). From my front end, I have a simple form with two fields - name and description. When the submit button is clicked, I get the following error: "new row violates row-level security policy for table "costcodes", code: 42501, details: Forbidden, hint: null". I used the "Enable delete for users based on user ID" template and selected "All" - didn't make any other changes. What am I missing?
    o
    g
    • 3
    • 5
  • diff not detecting changes
    j

    jdgamble555

    04/18/2023, 12:12 AM
    I configured my local host with a starting migration file with all of my tables, functions, and policies. I forgot to include one table I have, called redirects, in the migration file. I ran:
    npx supabase link --project-ref (my project id)
    then
    npx supabase db diff -f first_changes
    and I got the response:
    No changes found
    However, there is definitely a table on supabase.com that doesn't exists on my local host (redirects table). Is the diff function buggy, or am I not using it correctly? J
    n
    s
    • 3
    • 12
  • Can't successfully run a trigger before user creation
    k

    kekington

    04/18/2023, 1:26 AM
    I'm trying to create a trigger to limit user registration based on either a specific email or an email domain. This is the function that I created:
    Copy code
    BEGIN
        IF EXISTS(SELECT 1 FROM public.whitelist WHERE whitelist_string = NEW.email AND type = 'user') THEN
            RETURN NEW;
        END IF;
    
        IF EXISTS(SELECT 1 FROM public.whitelist WHERE whitelist_string = SUBSTRING(NEW.email FROM '@(.*)') AND type = 'org') THEN
            RETURN NEW;
        END IF;
    
        RETURN null;
    END;
    It never seems to correctly follow the logic and allow user creation. The logs are not very informative. If I run the conditional queries (the ones inside the IF statements), they return the results as expected. Furthermore, I had cases where it hit the last case (RETURN null;) and still allowed for user creation. I'm not sure what else I could try here. Would appreciate any pointers.
    n
    g
    • 3
    • 9
  • NextJS 13 app per request caching
    k

    kleveland

    04/18/2023, 1:29 AM
    There is a lot of documentation and articles with NextJS and Supabase but I found during the recent hackathon, in a bunch of the server components I would be fetching data from Supabase for auth and getting user data. There is a level of caching on NextJS per page but I was curious if caching and revalidation can be implemented on a per request basis using the react
    cache
    function.
    n
    g
    • 3
    • 10
  • Delete subscription response only returns payload.old.id
    p

    PSully

    04/18/2023, 2:02 AM
    I may be totally misunderstanding how this is supposed to work, but when I listen for
    INSERT
    events, I am returned:
    Copy code
    {
      ...
      new: { column1: "value", column2: "value", column3: "value", ... },
      old: {}
      ...
    }
    This lets me do something with the value that was inserted. However, when I get the response back from a
    DELETE
    event, I'm returned:
    Copy code
    {
      ...
      new: {},
      old: {
        id: 999
      }
      ...
    }
    Which means I can't really do anything with the value that was deleted. Sure, I could probably find ways around this, but I feel like I shouldn't have to, as it kinda feels like it defeats the purpose of this being RealtimeChannel. Am I doing something wrong here? Am I misunderstanding how this should work?
    g
    • 2
    • 4
  • Can't connect to Database
    s

    spy16

    04/18/2023, 2:31 AM
    My app is hosted on Fly.io and I am on Supabase free tier right now. Almost everyday, in the night the app is working. But by next morning, app is not able to connect anymore and it crashes. I can't connect to the database through psql client also after this point. only option is to restart the project. Is this due to some connection pool misconfiguration?
    g
    n
    • 3
    • 7
  • permission denied for schema public
    c

    cveering

    04/18/2023, 3:35 AM
    Hello... I'm following along with the Learn with Jason tutorial and am receiving the following error:
    permission denied for schema public
    . I am using the Project URL for the supbaseURL and the anon/public key for the supabaseKey in the client constructor. There is currently no RLS. I have also restarted the database. I was previously using Prisma on this system if that matters. Thanks in advance for your suggestions.
    g
    • 2
    • 4
  • Querying auth users
    k

    KurustyKrabs

    04/18/2023, 5:16 AM
    Hi everyone, I'm trying to query an auth users table by following this guide https://nikofischer.com/supabase-how-to-query-users-table. However, when I tried creating a new query, it displayed an error. Is this some kind of bug? Hope to find pointers for this. Many thanks.

    https://cdn.discordapp.com/attachments/1097752513601622066/1097752513823903815/image.png▾

    g
    • 2
    • 1
  • 401 :user not allowed at deleteUser()
    d

    darick

    04/18/2023, 5:47 AM
    I am using google sign-in in my supabase project. In the case that users want to delete their account, i tried this function but i got 401: user not allowed error. How can i fix this? const { data, error } = await supabase.auth.admin.deleteUser( session.user.id??'' )
  • Update Postgres tablet from an .sql file
    a

    aaale83

    04/18/2023, 7:11 AM
    Hi everyone I need to keep updated some tables on Postgres downloading a zip from an url. The steps are: 1) Download the zip file from an URL 2) Unzip file to get .sql file 3) Import .sql file into Postgres Can you please help me on what's the best solution to achieve this workflow? Edge Functions? if so what tools do i have to use? Thanks for the help! 🙂
1...183184185...230Latest