https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Is realtime having issues?
    b

    bpeck81_

    02/24/2023, 6:51 PM
    I havent made any code changes and it says im subscribed to my chatroom channel, but I'm not receiving a payload.
    g
    • 2
    • 17
  • type generation from dashboard results in error
    g

    Gravy

    02/24/2023, 7:54 PM
    I tried to generate types from supabase studio (self hosted) but for whatever reason I got this large block of html. I can't generate types from the CLI because I can't find my access token.
    s
    • 2
    • 9
  • Getting API Keys from .env in edge functions?
    g

    Gregory

    02/24/2023, 8:19 PM
    How do I reference my API keys in edge functions? I have a function in /supabase/functions/search/index.ts and I'm trying to pass in my OPENAI_API_KEY from .env at the root level.
    console.log('API key =', Deno.env.get('OPENAI_API_KEY'));
    API key = undefined Should I just hardcode it into the edge function?
    s
    t
    • 3
    • 3
  • set custom default value function
    j

    jt

    02/24/2023, 9:11 PM
    I want to have a random 4 digit discriminator be generated each time a row is created. I tried putting this in the default value but it just literally adds it, it doesn't perform the function: substr(md5(random()::text), 1, 4) also tried LPAD(TRUNC(RANDOM() * 10000), 4, '0') do i need to wrap them in something?
    g
    • 2
    • 10
  • supabase and typesense?
    m

    MarcMartin

    02/24/2023, 9:28 PM
    I'm working at building an application that will need a fairly powerful search function with geosearch, etc. I was looking at using typesense for that and I was wondering how that can work with supabase? I couldn't find any good resources on implementing the two? Anyone have experience in that? Or should I look at a different search provider?
  • Is it possible to change the supabase rate limit to something higher?
    j

    JoshTheNerd

    02/24/2023, 9:38 PM
    Is it possible to change the supabase rate limit to something higher?
    s
    • 2
    • 15
  • Service Role does not return data from a select with RLS enabled
    p

    ParanoidCoder

    02/24/2023, 9:46 PM
    I'm attempting to create a client using the service role key in order to clean up data from an e2e test. The odd thing is that everything works fine if RLS is disabled, but if I enable it then my result has no data. I thought that the service role was supposed to bypass RLS, but I even tried adding a RLS policy for the service role that is always true for selects and I still get no data returned. I feel like I'm missing something small so any help would be appreciated.
    g
    s
    • 3
    • 20
  • Creating cron job for updating materialized view
    m

    mohnish

    02/24/2023, 10:44 PM
    Hello, I just set up materialized views to speed up some of our dashboards. Is there a way in supabase to set up cron jobs to refresh the materialized views frequently?
    g
    • 2
    • 2
  • check if value is in jsonb array of objects? have tried github solution and reddit. still not workin
    d

    Domcario

    02/24/2023, 11:52 PM
    https://github.com/supabase/supabase/discussions/7373 table
    subevents
    with jsonb column
    assigned_to
    . given array of javascript objects, i would like to filter for
    value.uuid
    = someUUID
    Copy code
    [
        {
            "label": "adfscxz",
            "value": {
                "uuid": "2238957c-7d05-48fb-b829-6c3221015068",
                "email": "vcxbcvbx@vcxbcvbx.com",
                "phone": "",
                "last_name": "ewtterw",
                "company_id": "c68f4ea0-9b31-4105-91dd-48627cea08df",
                "created_at": "2022-11-03T20:02:14.897281+00:00",
                "first_name": "bvnnb",
                "favorite_url": "/dd/The-Planning-Company/221",
                "email_verified": true,
                "phone_verified": false,
                "profile_pic_url": " vc bvc cbv.com/a/AEdFTp5g6U2HnEAdIgCv34qyf5h1eK-uMiPCTHJf0v4cXg=s96-c"
            },
            "disabled": false
        },
        {
            "label": "adfscxz",
            "value": {
                "uuid": "f1d9710b-a145-44ea-a00f-87b7740ed272",
                "email": "mkandan@asu.edu",
                "phone": "+14808531003",
                "last_name": "ewtterw",
                "company_id": "c68f4ea0-9b31-4105-91dd-48627cea08df",
                "created_at": "2023-02-08T14:53:49+00:00",
                "first_name": "bvnnb",
                "favorite_url": "/dd/The-Planning-Company/222",
                "email_verified": true,
                "phone_verified": false,
                "profile_pic_url": " vc bvc cbv.com/a/AEdFTp4isLRCN73tmGrPqK7RSOE1jO3qCM_8tF7FNJgVvw=s96-c"
            },
            "disabled": false
        }
    ]
    Copy code
    js
    const { data: subeventData, subeventError } = await supabase
                .from('subevents')
                .select()
                .eq('assigned_to->value->uuid', "2238957c-7d05-48fb-b829-6c3221015068")
    g
    • 2
    • 20
  • Getting information from raw_user_meta_data in trigger
    b

    Benanna19

    02/25/2023, 12:24 AM
    I found a reference to a post a while back that is the issue I am experiencing. In it the original poster mentioned using extensions in their trigger to get the correct information from raw_user_meta_data. Basically the issue I am having is destructuring that json data in the trigger. This is the other post - https://discord.com/channels/839993398554656828/869405720934744086/945820328234455041.
    • 1
    • 1
  • RLS saying my expression has an error
    j

    JoshTheNerd

    02/25/2023, 2:29 AM
    I'm getting this error when I try to save this SQL query
    Copy code
    sql
    SELECT
        CASE WHEN EXISTS 
    (SELECT 
       *
    FROM 
       "Messages"
    WHERE "conversation_id" = (SELECT 
       conversation_id
    FROM 
       "Conversations"
    WHERE "author_id" = auth.uid() OR "contact_id" = auth.uid() )
    AND author_id NOT IN (auth.uid()))
    THEN true
        ELSE false
    END
    g
    • 2
    • 18
  • Viewing postgres logs
    n

    Noah Burroughs

    02/25/2023, 3:08 AM
    I used the documentation here: https://supabase.com/docs/guides/platform/logs to enable logging (adding the extension, enabled pgaudit.log in sql editor, and restarted my project). I issue queries on my localhost to my database and see them in my api edge network tab but not in my postgrest tab. Is there an extra step I am missing? I'd like to see the logs to troubleshoot some RLS problems
    g
    • 2
    • 2
  • Get domain URL when generating OG image
    j

    jinsley8

    02/25/2023, 4:14 AM
    I'm following this guide to generate og image with edge function. https://supabase.com/docs/guides/functions/examples/og-image Is there a way to get the domain URL of the website to use for an image URL within the og-image? Or is it easier to just pass the domain as a query param?
  • Bug: supabase o auth redirect not working
    h

    Holland

    02/25/2023, 5:47 AM
    I am using protected routes like this:
    Copy code
    export const getServerSideProps: GetServerSideProps = async (ctx) => {
      // Create authenticated Supabase Client
      const supabase = createServerSupabaseClient(ctx)
      // Check if we have a session
      const {
        data: { session },
      } = await supabase.auth.getSession()
      console.log('session', session)
    
      if (!session)
        return {
          redirect: {
            destination: '/login',
            permanent: false,
          },
        }
    
      return {
        props: {},
      }
    }
    When redirecting on google sign in, session is null for some reason. When I refresh the page I magically get a session and the user appears to me and I can access the protected route. I am using next js.
    i
    s
    • 3
    • 4
  • useUser hook returning null when redirecting back from Stripe hosted payments page
    s

    swiftarrow

    02/25/2023, 7:06 AM
    I'm using Stripe's payment link that redirects back to my NextJS app that uses Supabase backend. I'm using a useUser hook that always returns null when redirecting back from the payment page. It seems similar to some other issues I've seen. e.g. https://github.com/supabase/auth-helpers/issues/52 Any thoughts on how to address?
    s
    • 2
    • 4
  • Auth: works local but not in prod
    m

    misakss

    02/25/2023, 10:15 AM
    I'm sure this is a trivial error but I cannot find a solution after some Googling. My Supabase authentication works in local development, but not when I deploy on Vercel. I receive the following error: Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error. (I use NextJS App Dir) Any guide on how to fix this?
    s
    • 2
    • 7
  • SQL for creating new policy allowing authenticated users to insert only is a column is same as user
    i

    ImJune

    02/25/2023, 10:37 AM
    I have a table called ebooks with rows a foreign key row called user. and i want to create a policy which checks only the users can only insert if the user column is same as the id of the user who is inserting. i hope u understand. here is what i tried,
    Copy code
    CREATE POLICY "Enable insert for authenticated users only" ON "public"."Ebooks"
    AS PERMISSIVE FOR INSERT
    TO authenticated
    
    WITH CHECK (auth.uid() = user)
    it throws this error
    Copy code
    Error adding policy: failed to create pg.policies: operator does not exist: uuid = nameError adding policy: failed to create pg.policies: operator does not exist: uuid = name
    any help would be great, thanks
    s
    • 2
    • 1
  • How to create a GET endpoint?
    r

    rattlesnake

    02/25/2023, 11:31 AM
    Hey all. Love supabase! Is there a way to create a GET endpoint using Edge Function? Or does Edge Function support PUT/PATCH/DELETE/GET endpoints?
    s
    • 2
    • 3
  • not eql with and
    e

    eloahsam

    02/25/2023, 11:49 AM
    im still new to supabase , i have a table with 6 columns and i would like to select all rows except rows where (column 1 = id "and" column 4 = "value") or (column = null) im using the javascript v2 sdk on nextjs i havent seen the and clause
    z
    g
    • 3
    • 17
  • How do you push on the prometheus on grafana cloud ?
    a

    Alaanor

    02/25/2023, 12:13 PM
    I think you somewhat need to have a intermediate agent that first scrape and then send back to the master (the one on grafana cloud). I wanted to hear how people here did it, do you really need another server for that ? lemme know
  • Invalid certificate on new project API endpoint
    z

    zngb

    02/25/2023, 12:50 PM
    I created a new project for a dev environment yesterday and it worked for about an hour. Then I started getting ERR_CERT_AUTHORITY_INVALID in Chrome when I try to connect to the Supabase dashboard (it hangs on "Connecting to project") and also my client and backend API calls return an error regarding the invalid certificate. Temporary hiccup for the weekend? It happened with another new project I created and then I destroyed and recreated it, but the issue seems to persist.
    • 1
    • 1
  • signInWithOAuth
    s

    saswatsaubhagya

    02/25/2023, 1:04 PM
    flutter oauth is not working as it should in flutter. Anyone implement that in flutter . need some help.
    s
    • 2
    • 2
  • How can I insert auth users using SQL?
    m

    mrmikardo

    02/25/2023, 1:40 PM
    Specifically, how should I hash passwords to allow users to later login using the Supabase JS client? At the moment, I am creating entries in
    auth.users
    with the following snippet;
    Copy code
    INSERT INTO auth.users (id, instance_id, aud, role, email, encrypted_password, email_confirmed_at)
    VALUES (
            gen_random_uuid(),
            gen_random_uuid(),
            'authenticated',
            'authenticated',
            'test_user@witihpluto.com',
            crypt('password', gen_salt('bf')),  <-- this is the line I am unsure about!
            now()
            );
    I can see that users are successfully inserted with a hashed password. However, when I later try and log this user in via the Supabase JS client, I'm getting an error from the database.
    s
    g
    • 3
    • 21
  • Error querying data on flutter
    c

    CauaLW

    02/25/2023, 3:30 PM
    Hey, I am trying to search patients based on the name field, and limiting the query to 5 docs Here's the code to get the data:
    Copy code
    Future<ReturnData> searchPatients(String param) async {
        try {
          List<Patient> searchedPatients = await _table.select().eq('user_id', UserProvider().user.id).ilike('name', '%$param%').order('id').limit(5).withConverter<List<Patient>>((patientsList) => patientsList
              .map<Patient>(
                (p) => Patient.fromJson(p),
              )
              .toList());
          return ReturnData(isOk: true, message: '', data: searchedPatients);
        } catch (e, s) {
          if (kDebugMode) {
            print('Error on searchPatients: $e');
            print(s);
          }
          return ReturnData(isOk: false, message: 'Ocorreu um erro ao buscar os pacientes, por favor tente novamente mais tarde');
        }
      }
    and here is the error I'm facing: PostgrestException(message: JSON object requested, multiple (or no) rows returned, code: PGRST116, details: Results contain 5 rows, application/vnd.pgrst.object+json requires 1 row, hint: null)
    g
    • 2
    • 4
  • Python eq. filter error
    j

    jumeh

    02/25/2023, 3:30 PM
    Hi peeps, I'm having an error while trying to filter a fetch on one of my table. postgrest.exceptions.APIError: {'code': 'PGRST104', 'details': 'Failed to parse [("status","Filters.EQ.0")]', 'hint': None, 'message': 'Unexpected param or filter missing operator'} the goal is to perform: eq.("status", 0) on a select. Can someone help on that? Thanks
    g
    • 2
    • 2
  • service_role key and Migrations
    j

    jfischoff

    02/25/2023, 4:46 PM
    The next.js example includes a storage trigger which hard codes the service role key. However, this is a secret and thus should not go into source control. If I want to make sure all of db setup is in migrations, how can I recreate the behavior from the next.js tutorial without hardcode the service_role key in the migration?
    s
    w
    • 3
    • 6
  • what to do to manage state nextjs 13
    g

    Grimmjoww231

    02/25/2023, 4:54 PM
    the way i understood it is that supabase returns id on sign in. while im used to getting back a token. is there a state management where we could do this and be able to store data on the client side that is prefered and maybe some links that i could be directed to ?
    g
    • 2
    • 1
  • is it safe to use supabase admin key like this (this is from official vercel github)?
    c

    Cheqo

    02/25/2023, 5:00 PM
    Hello, I came across this official supbase next js template and I noticed
    supabase-admin.ts
    file is in the utils folder. That means it's being used client side and is exposed? Am i missing something or is it okay to use it like this? here is the link of the file. https://github.com/vercel/nextjs-subscription-payments/blob/main/utils/supabase-admin.ts
    g
    • 2
    • 1
  • Supabase Auth + Prisma - am I doing it wrong?
    d

    drunkenxwizard

    02/25/2023, 5:03 PM
    πŸ‘‹ Hey everyone! I'm trying to setup Prima as an ORM with Supabase auth. I've been through a bunch of posts on here as well as many GitHub issues on this topic but I'm still running into problems. Apologies if the question has been answered before β€” I searched a fair amount and didn't come up with anything. Context: - I'm using Remix (but I believe that's not particularly relevant) - All my requests to Supbase will be server side, hence I don't need RLS What I've done so far: - Followed the Prisma guide here: https://supabase.com/docs/guides/integrations/prisma - Created a
    Users
    table in the
    public
    schema - Used to triggers and functions mentioned here (https://github.com/supabase/supabase/discussions/7659#discussioncomment-4475351) to insert rows into this
    public.Users
    table - To be sure that these functions and triggers are saved in GitHub, I added them to the top of the initial migration file β†’ 🚨 I believe this is the cause of the issue *This discussion helped me quite a bit: https://github.com/supabase/supabase/discussions/7659 - thank you @NanoBit! * βœ… All of that is working fine The issue: - I Updated the
    schema.prisma
    file to insert a new model - I want this to be recorded as a "migration" so I ran
    npx prisma migrate dev --name add-api-keys
    At this point, I run into an error:
    Copy code
    Migration `20230225153045_init` failed to apply cleanly to the shadow database.
    Error:
    db error: ERROR: schema "auth" does not exist
       0: migration_core::state::DevDiagnostic
                 at migration-engine/core/src/state.rs:269
    This, of course, makes sense as the shadow DB won't have any idea of the
    auth
    schema. My question: Am I approaching this incorrectly? If you have Supabase auth + Prisma working, what approach have you followed? Thank you so much!
    n
    • 2
    • 6
  • How to do a join with a subscription
    h

    Holland

    02/25/2023, 5:26 PM
    Hey, so I have a list of PostsResponse elements that looks like this. Its from a join.
    Copy code
    type PostsResponse = Post & {
      users: {
        first_name: string | null
        last_name: string | null
      }
    }
    
    const { data, error } = await supabase.from('posts').select(`
        post_id,
        title,
        content,
        likes,
        user_id,
        users(
          first_name,
          last_name
        )
      `)
    I have a subscription listening for new posts. What is the best way to get a subscription event then join it with data from another table? Here is what I have:
    Copy code
    postsSubscription = supabase
            .channel('custom-insert-channel')
            .on(
              'postgres_changes',
              { event: 'INSERT', schema: 'public', table: 'posts' },
              (payload) => {
                console.log('Change received!', payload)
              }
            )
            .subscribe()
    Should I do another call inside the payload function to join the tables and get the data I need? I'm using nextjs and typescript.
    g
    j
    • 3
    • 17
1...145146147...230Latest