https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Considering using the free instance as a staging/pre-prod env
    v

    ven

    05/09/2023, 11:41 AM
    Since Supabase offers two instances I am evaluating using the free instance as a pre-prod environment to mitigate migration risks. Has anyone tried this with Supabase where you use the paid version for prod and the free instance for pre-prod? pros/cons of this strategy? thanks
    n
    • 2
    • 7
  • rls policy for custom role not working
    a

    aar2dee2

    05/09/2023, 11:43 AM
    I read through the discussions on this channel for setting up custom claims and roles in Supabase. I've tried both approaches after referring the Github discussion, but I'm not getting the data after setting policies on the table. Here's my code: 1. Create and use an
    f1omo_staff
    role:
    Copy code
    sql
    -- new role for staff
    CREATE ROLE "f1omo_staff" WITH LOGIN INHERIT;
    GRANT "f1omo_staff" TO authenticator;
    GRANT anon, authenticated to "f1omo_staff";
    
    GRANT USAGE ON SCHEMA "public" TO "f1omo_staff";
    
    ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES  TO "f1omo_staff";
    ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS  TO "f1omo_staff";
    ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES  TO "f1omo_staff";
    
    CREATE POLICY "Allow all for f1omo_staff users" ON "public"."feed_css_selector"
      FOR ALL TO "f1omo_staff"
      USING (true);
    
    CREATE POLICY "Allow read access for f1omo_staff" ON "public"."feed"
      FOR SELECT TO "f1omo_staff"
      USING (true);
    
    CREATE POLICY "Allow all for f1omo_staff" ON "public"."digest"
      FOR ALL TO "f1omo_staff"
      USING (true);
    The policies show up in the Supabase dashboard. I can see the logged in user's role set to
    f1omo_staff
    on after logout and login again. But when I try to read the
    feed
    table using the supabase client I get
    Copy code
    data []
    error null
    . Here's the client side code:
    Copy code
    ts
    export const getAllFeeds = async () => {
      const { data, error } = await supabase
        .from("feed")
        .select("*")
        .order("newsblur_feed_id", { ascending: false });
      console.log("data", data);
      console.log("error", error);
      if (error) {
        console.log(error);
        return [];
      }
    
      return data;
    };
    
    export async function getStaticProps() {
      const feeds = await getAllFeeds();
      return {
        props: {
          feeds: feeds,
        },
        revalidate: 600,
      };
    }

    https://cdn.discordapp.com/attachments/1105459979386892409/1105461400781991977/Screenshot_2023-05-09_at_5.16.13_PM.png▾

    g
    • 2
    • 78
  • Managing environments with self-hosted
    t

    TheRien

    05/09/2023, 1:08 PM
    I want to use self-hosted Supabase combined with a local development setup. In fact, I eventually want to run a local -> acceptance -> production strategy with supabase. I've already found this page about managing environments: https://supabase.com/docs/guides/cli/managing-environments And this one about self-hosting Supabase: https://supabase.com/docs/guides/self-hosting/docker Now my question is, what do I enter here to combine them?
    supabase link --project-ref $HELP
    v
    g
    • 3
    • 32
  • Supabase Upload Image w/ React Native CLI
    m

    Merovingian

    05/09/2023, 1:27 PM
    Hi, I need help about uploading Profile Photos to my Supabase Storage. Basic Info: I have a profile table which is the same as user-management profiles table. So I have an avatar_url column. Then in my react native cli, I am using react-native-image-picker. I can get an image and I can see on profile page but It is just statically. I want to upload that to my supabase storage but When I upload that image to the s+s , I am getting a broken image or Internal Server Error
    Copy code
    const openGallery = async () => {
        const options: ImageLibraryOptions = {
          mediaType: 'photo',
          includeBase64: false,
          maxHeight: 200,
          maxWidth: 200,
        };
        launchImageLibrary(options, async result => {
          if (result.didCancel) {
            console.log('User cancelled image picker');
          } else {
            const localUri = result?.assets?.[0]?.uri;
            const userId = user?.id; // user's id.
            setAvatarUrl(localUri);
    
            if (localUri && userId) {
              await uploadAvatarToSupabase(localUri, userId);
            }
          }
        });
      };
    
      const uploadAvatarToSupabase = async (localUri, userId) => {
        const response = await fetch(localUri);
        console.log('response', response);
    
        const blob = await response.blob();
        console.log('blob', blob);
    
        const fileExtension = localUri.split('.').pop();
        console.log('fileExtension', fileExtension);
        const fileName = `${userId}.${fileExtension}`;
        console.log('fileName', fileName);
    
        const {data, error} = await supabase.storage
          .from('profilePhotos')
          .upload(fileName, decode('includeBase64'), {
            cacheControl: '3600',
            upsert: true,
            contentType: `image/${fileExtension}`,
          });
        console.log('data', data);
    
        if (error) {
          console.error('Upload Failed:', error.message);
        } else {
          console.log('Upload Successful');
        }
      };
    And there is a response: 👇
    g
    • 2
    • 6
  • Is refresh token expiration equal to jwt expiration?
    e

    Epailes

    05/09/2023, 1:46 PM
    I'm getting the below error when attempting to generate a new
    access_token
    for a user using the
    refresh_token
    after the
    access_token
    has expired:
    Copy code
    AuthApiError: Invalid Refresh Token: Already Used
        at E:\Programming\Projects\ArtPage-SvelteKit\node_modules\@supabase\gotrue-js\dist\main\lib\fetch.js:41:20
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
      __isAuthError: true,
      status: 400
    }
    I'm using this command:
    const {data, error} = await userClient.auth.refreshSession({refresh_token});
    If I attempt to run that before the access_token expires, it works correctly so I know it's not an issue with something in my application errantly using the refresh_token meaning it's actually used. I'm running supabase on my local machine, and I've set
    jwt_expiry = 60
    just to make testing this easier. Is this the intended behaviour? I thought refresh_tokens didn't expire as they're meant to be long lived...
    g
    a
    • 3
    • 13
  • how can i use createServerSupabaseClient(ctx) in getstaticpaths and getstaticprops
    s

    SkyNightSnow

    05/09/2023, 2:40 PM
    I have a problem that does not show me the data to be able to form the page I want, it only works for me with const supabase = createServerSupabaseClient(ctx) with getServerSideProps I can't find a documentation that teaches how to use createServerSupabaseClient with getStaticPaths and getStaticProps

    https://cdn.discordapp.com/attachments/1105504609100902481/1105504609746813030/image.png▾

  • React-native/Expo OAuth
    m

    Matt Freeman

    05/09/2023, 3:26 PM
    Hi everyone I'm trying to setup google and facebook OAuth in my react-native app and hitting a bit of a wall First is there a know way to accomplish this that my days of searching haven't turned up? If not what I have done so far is use expo-auth-session to get an access token from google/facebook then use that to get the user info. From there I get a bit stuck, how do I pass the user info to supabase so that it registers as OAuth properly? Or More generally what does Supabase pass to the Db to register a user with Oauth?
  • [SOLVED] DB Migration Error
    m

    MartiN

    05/09/2023, 3:38 PM
    I followed this migration guide: https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#migrate-your-project I checked all prerequisites and I ran
    npx supabase db dump --db-url "$OLD_DB_URL" -f roles.sql --role-only
    and got
    Dumping roles from remote database...
    Error: Error running pg_dump on remote database: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
    Try rerunning the command with --debug to troubleshoot the error.
    I tried running with --debug but got the same thing. I have docker, and postgres on my mac. I restarted docker and ensured it is running but nothing changed. At some point it asked me to run
    supabase link
    so I created a local supabase project using
    supabase init
    , I logged in with
    supabase login
    , and ran
    supabase link --project-ref <my_project_ref>
    , but then again got the same error.
    n
    • 2
    • 16
  • Verify password hash in PostgreSQL?
    d

    dave

    05/09/2023, 3:47 PM
    Is it possible to hash and verify if a string matches a user's hashed password? I know I can get the user's password hash with this:
    Copy code
    sql
    -- Create a function to get the encrypted_password for a specific user by email
    CREATE OR REPLACE FUNCTION get_encrypted_password(p_email TEXT)
    RETURNS TEXT
    LANGUAGE plpgsql
    SECURITY DEFINER
    AS $$
    BEGIN
        RETURN (
            SELECT auth.users.encrypted_password
            FROM auth.users
            WHERE auth.users.email = p_email
        );
    END;
    $$;
    I can't do bcrypt easily in my application, so doing it in PostgreSQL would be ideal. For context, I'm trying to workaround the rate limiting on the auth endpoints for our server-side application.
    n
    g
    • 3
    • 11
  • Storage Egress
    m

    mikel

    05/09/2023, 3:48 PM
    Hey there, I wanted to ask a question about storage egress with Supabase. If I store the public URLs of my users' images in a JSONB cell and then use Node.js to make API requests for this cell to display the images based on the URL source, will it count towards the storage egress? Another example is if I have a blog where each blog post's data is inside the Supabase database. Every time someone visits the post, it will make an API call to retrieve the data. If I store the public URL in a string cell and display
    <img src={supabase_post.image}/>
    , will it count towards the storage egress every time someone views the post because of the image public URL? (Again, I'm not calling the public URL from the bucket every time. The public URL is already stored in a database cell.) Thanks!
    g
    • 2
    • 5
  • replication & metabase read-only
    n

    nimo

    05/09/2023, 3:53 PM
    Hey, I'd like to create a replica of my db that is read only to allow a Metabase instance to query data and not affect production instances at all. I've read the replication blog but not sure it answers my question fully. What is the best way of doing this?
    g
    • 2
    • 4
  • Latest version of supabase studio does not connect to project
    y

    Yuu

    05/09/2023, 4:21 PM
    I updated to supabase/studio:latest (20230509-e3eac96) from supabase/studio:20230330-99fed3d and now it won't connect to the project. I get CORS errors where it tries to connect to localhost:8000, which isn't exposed. I do not have localhost anywhere in my .env My config: If there any more information I need to provide, please let me know
  • Preparing Object for Mass Update [SOLVED]
    d

    DignifiedSwine

    05/09/2023, 4:28 PM
    I am trying to make an object for an update but have 2 items that need to be excluded, for some reason the conditions are being ignored - can anyone help? Code:: // Clear Profile var toClear = document.getElementById('profile') var updateobject = {}; var inputs = getAllInputs(toClear); // Returns all Inputs, Textareas, and Selected for (var x = 0; x < inputs.length; x++) { console.log(inputs[x].id); if (inputs[x].id != "college" || inputs[x].id != "year") { updateobject[inputs[x].id] = null; } else { console.log("hit"); if (inputs[x] == "college") { updateobject[inputs[x].id] = 6; } if (inputs[x] == "year") { updateobject[inputs[x].id] = 1; } } } _supabase.from('_tblStudents').update(updateobject).eq('id', sessionStorage.getItem("Student_Id")).then(response => { }) Output:: name age gender race subrace class subclass level alignment height weight haircolour eyecolour background year // What im expecting is the next one to say "hit" personalitytraits ideals bonds flaws goals backgroundfeatures appearance college // What im expecting is the next one to say "hit"
    g
    • 2
    • 3
  • Generating supabase types of views makes all fields nullable
    s

    sili

    05/09/2023, 4:33 PM
    I have some table views defined in supabase. When I generate types, all fields of views are nullable. Is there a reason for it or is this a bug?
    i
    • 2
    • 1
  • Why is a join returning DBType | DBType[]
    s

    SANTlAG0

    05/09/2023, 5:09 PM
    Im currently using the following query:
    Copy code
    const { data, error } = await supabase
              .from("profiles") // Updated with 2 type arguments
              .select(
                `
                username,
                  credits,
                  accounts: accounts!profile_id (
                    id,
                    account_name,
                    account_password,
                    whatsapp_number,
                    subscription_start_date
                  )
                `
              )
              .eq("id", user.id)
    However it seems accounts can be of type
    Account | account[] | null
    Where I would expect an array with one, empty array or array with accounts. How can I make sure an array is always returned
    g
    • 2
    • 2
  • auth-helpers-react in nextjs app directory
    u

    매튜

    05/09/2023, 5:33 PM
    I'm updating https://github.com/vercel/nextjs-subscription-payments/ to use the new nextjs app directory using middleware and the supabase-providor as shown in this repo https://github.com/supabase/supabase/tree/master/examples/auth/nextjs. Log in log out flow works fine with auth ui, but it looks like auth-helpers-react is not getting any of the user data, is this a known issue?

    https://cdn.discordapp.com/attachments/1105548161579241512/1105548161826684948/0.png▾

  • Twilio rate-limiting issue with Supabase OTP Auth
    m

    Miles

    05/09/2023, 5:41 PM
    We're using SMS OTP auth with Twilio as our provider, but in our small beta launch (~200 users) we're getting heavily rate limited when trying to log in with SMS OTP. I understand the error (429: rate limit) is likely just Supabase propagating the Twilio error, but I was wondering if anyone had advice on how to up the rate limit of Twilio? We're on a payed plan but I don't see how to up the limit, and it seems like if even just 5 people try to request a code at once it will block people for minutes. Any advice would be super appreciated!
    o
    r
    g
    • 4
    • 5
  • Realtime stream emits incomplete Data
    w

    Wizzel

    05/09/2023, 5:54 PM
    I have a realtime table that contains a column called
    json_data
    of type
    jsonb
    and
    allow_nullable
    is set to false. When I update another column in this table and row, the stream emits data where
    json_data
    is null. When I check the respective row,
    json_data
    is not null. Why is the emitted data from the stream incomplete?
    g
    • 2
    • 9
  • insert postgres changes working, but not update..
    m

    malphine2

    05/09/2023, 6:18 PM
    heres my code
    Copy code
    Future<void> listenToOrderTableInsert() async {
        supabase.channel('public:order').on(
          prefix.RealtimeListenTypes.postgresChanges,
          prefix.ChannelFilter(
              event: 'INSERT',
              schema: 'public',
              table: 'order',
              filter:
                  'company_id=eq.${getProvider()!['company_id'].toString()}'),
          (payload, [ref]) {
            print('Change received: ${payload['new']['company_id']}');
            orders!.add(payload['new']); 
            notifyListeners(); 
          },
        ).subscribe();
      }
        Future<void> listenToOrderTableUpdate() async {
        supabase.channel('public:order').on(
          prefix.RealtimeListenTypes.postgresChanges,
          prefix.ChannelFilter(
              event: 'UPDATE',
              schema: 'public',
              table: 'order',
              filter:'company_id=eq.${getProvider()!['company_id'].toString()}'),
          (payload, [ref]) {
            print('Change received: ${payload['new']['company_id']}');
        
          },
        ).subscribe();
      }
    g
    • 2
    • 8
  • Edge function invoking functionality of another Edge function
    v

    viktor

    05/09/2023, 6:21 PM
    We do have a _shared folder for code _shared between Edge function, but this function is quite specific and doesn't really fit the theme of our other shared code. If I have an exported function inside an Edge function, can I import that function from another Edge function? Alternatively can I invoke an Edge function from another Edge function, and if so is there the normal request server delay or is there some local host magic?
    v
    • 2
    • 3
  • auth0
    n

    nicollegah

    05/09/2023, 7:04 PM
    looking for someone to help me with migration from auth0 to supabase auth in nextjs/typescript. am willing to pay
    g
    • 2
    • 2
  • Anyone available for a 1:1 session to help implement auth with next.js?
    e

    eusoubrunocamargo

    05/09/2023, 7:09 PM
    I need to set auth for login and signup pages
    s
    • 2
    • 1
  • Slow writes - 1-2s!!
    p

    phemartin

    05/09/2023, 7:19 PM
    I'm using Prisma + Nextjs on the backend... and my writes are taking 1-2s each! They are pretty basic as well: write
    contentHtml
    +
    userId
    It seems pretty slow. Is that normal? How can I speed things up? The only reason I can think of is that sometimes the
    contentHtml
    payload is large ~0.5mb and may be affecting performance.
    g
    n
    • 3
    • 22
  • Supabase realtime C++ client and Websockets protocol
    t

    Thierry-Hackeet

    05/09/2023, 7:45 PM
    Hi, Do you know if there is a C++ real-time client for Supabase and, if not, is there any documentation describing the websocket protocol used to subscribe to real-time events (like the one implemented in supabase-js for example)? Thanks a lot.
    g
    • 2
    • 6
  • Generate img links that dont expire.
    j

    jj_sessa

    05/09/2023, 7:48 PM
    Is there a way / best practice on generating links that dont expire? The js function required a expiresIn so i figured its not best practice to have them last forever, would appreciate some insight and education on this!
    g
    • 2
    • 3
  • How do you keep track and maintain SQL databases?
    d

    dave

    05/09/2023, 8:12 PM
    Right now, I'm just writing SQL and running in the web UI to create tables and such, but this is a pretty poor practice. e.g. I want our dev/staging and production setups to stay in sync, and have my changes tracked with Git.
    o
    v
    v
    • 4
    • 9
  • where to find console.log() for local hosted edge functions
    v

    ven

    05/09/2023, 8:59 PM
    Where will i see them? i am using the docker desktop. i checked in the deno container and Kong. couldn't find them there.
  • Is it possible to see how Supabase auth sends the Twilio messages to users?
    r

    Ryan [untitled]

    05/09/2023, 9:23 PM
    I can see that my app is calling https://xxxxxxxxxx.supabase.co/auth/v1/otp but we are getting rate limited on the number of sms we are able to send in our auth. This leads us to believe that supabase is using the Twilio messaging service instead of the Twilio verify service.
    g
    • 2
    • 16
  • Migration Management
    g

    Grantly

    05/09/2023, 9:34 PM
    Hello Everyone! I have recently "upped my game" on versioning and migrating my database schemas. Still, I am wondering if I am running things the best/most efficient ways. I would love any feed back on my workflow and insight on how others are working differently. Currently My flow looks like this: Local (create changes using the "Studio URL": http://localhost:54323) > > npx supabase db diff -f GrantlyCoolMigration > > npx supabase link --GrantlyCoolStaging > > npx supabase db push I test things in Staging make sure I like how everything works... > npx supabase link --GrantlyCoolProduction > npx supabase db push We are live in production! I feel slightly confused about a couple things. 1) Should I delete old migration files locally? I have a directory with tons of old migration files. Is it ok for those to all accumulate? Does Supabase know to only push the "unpushed" ones? 2) I have not found myself needing to use "supabase db remote commit" very frequently. When are people using this?
    v
    v
    • 3
    • 3
  • Supabase Edge Function Execute Function AFTER returning response
    n

    Nin

    05/09/2023, 10:00 PM
    I'd like my Edge Function to respond with a 202 Accepted and continue processing the request in the background. Is that a possibility and if so, how?
    n
    v
    a
    • 4
    • 13
1...207208209...230Latest