https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Can someone help give every authenticated user the right to delete images in a bucket?
    s

    SGreen

    05/02/2023, 11:33 AM
    Hey there guys, I want every auth user to be able to delete images, sadly that doesn't work. My knowledge about supabase and sql is limited. I would really appreciate help!💚
  • Channel gets subscribed but not showing payload
    p

    Pushpalatha

    05/02/2023, 11:34 AM
    have created table called chat_message in supabase and written code to get read message while inserting the message in it.the channel gets subscribed but payload not showing while console logging .My code var supabase = supabase.createClient(SUPABASE_URL, SUPABASE_KEY) async function login_supabase() { var sp_email=$('.spa_email').val(); console.log(sp_email); var spa_ps=$('.spa_ps').val(); console.log(spa_ps); if (sp_email) { const { data: { user }, error } = await supabase.auth.signInWithPassword({ email:sp_email, password:spa_ps, }) } } async function get_user() { // const user1 = supabase.auth.user() const datas= await supabase.auth.getSession(); console.log(datas); if (datas) { window.userToken=datas.data.session.user.id; console.log(datas.data.session.user.id); } } async function read_message() { console.log(loged_user_common); const userListener = supabase.channel('chat_messages:receiver_id=eq.'+loged_user_common+'') .on( 'postgres_changes', { event: '*', schema: 'public', table: 'chat_messages',filter:'receiver_id=eq.'+loged_user_common+'' }, (payload) => { // console.log('Change received!', payload) console.log(payload); }) .subscribe() } login_supabase().then(function() { get_user(); read_message(); })
    u
    g
    • 3
    • 3
  • supabase postgis with openstreetmap
    k

    Killtec

    05/02/2023, 1:14 PM
    Hello, does anyone have experience with this? If i want to upload openstreetmaps data from germany for example, is this possible? Or will i run into major issues?
  • Twitter Login seems Not Working anymore
    p

    prattjc

    05/02/2023, 2:38 PM
    It looks like the Twitter Login doesn't seem to work anymore even if I added the API Key and Secrets in the provider and added the callback URI on Twitter Dev Tools.

    https://cdn.discordapp.com/attachments/1102967457402060891/1102967457620168714/image.png▾

  • Inngest workflow jobs
    v

    vick

    05/02/2023, 2:54 PM
    Has anyone managed to get Inngest endpoints to run in Supabase edge functions? They have examples for running it in various frameworks, including Deno Fresh so it should be able to run ok on Supabase edge functions as they also run in Deno. I just don't know the magic incantation to convert their "handler" function to a server loop that uses it. I'm interested to use it to run step functions to process larger backend data jobs.
  • Permission denied error when calling delete_user stored procedure
    b

    B-Train

    05/02/2023, 3:09 PM
    Dear Supabase Support Team and community. I have been encountering an issue with my stored procedure, delete_user, when trying to delete a user and their related records in my application. I am using Supabase for my backend and Next.js for my frontend. Here is the stored procedure I created: CREATE OR REPLACE FUNCTION delete_user(p_user_id uuid) RETURNS void AS $$ BEGIN DELETE FROM appointments WHERE appointments.user_id = p_user_id; DELETE FROM tasks WHERE tasks.user_id = p_user_id; DELETE FROM documents WHERE documents.user_id = p_user_id; DELETE FROM auth.users WHERE id = p_user_id; END; $$ LANGUAGE plpgsql; When I call this stored procedure from my Next.js API route, I receive the following error message: Error while calling the delete_user stored procedure: { code: '42501', details: null, hint: null, message: 'permission denied for table users' } I have tried creating and altering policies to grant the necessary permissions but the issue persists. Additionally, I encountered a foreign key constraint violation error when attempting to delete a user, which I have not been able to resolve: Error while calling the delete_user stored procedure: { code: '23503', details: 'Key (id)=(543081e0-ed71-4553-994f-64b850c736a8) is still referenced from table "objects".', hint: null, message: 'update or delete on table "users" violates foreign key constraint "objects_owner_fkey" on table "objects"' } I will very much appreciate your guidance
    g
    • 2
    • 1
  • Is the IP address from Postgres web hook fixed?
    i

    IrvingOu

    05/02/2023, 3:10 PM
    I have a service depending on the web hook from Postgres on Supabase cloud. I wanna configure a firewall that only allow the incomming request from supabase ip . Thanks
    g
    • 2
    • 1
  • Uploading data by id in supabase storage and fetching it by Id
    r

    Revaycolizer

    05/02/2023, 3:14 PM
    I am having trouble uploading and fetching files by Id I am using nextjs 13.3.1 below is the link to how i implemented it https://stackoverflow.com/questions/76147557/fetching-data-in-nextjs-13-3-1-using-supabase
    g
    • 2
    • 85
  • Syntax help using .ilike in a table column and a foreign table column at the same time
    v

    vonrie

    05/02/2023, 3:25 PM
    Hi, would like to an
    or
    operation for
    ilike
    supabaseClient.from('analyzers').select('id,name,imgUrl,manufacturers(name),departments(name,labs(name)),tests(count)').or('name.ilike.%org%,manufacturers.name.ilike.%org%')
    g
    • 2
    • 8
  • deleting user's files
    k

    Kasoa

    05/02/2023, 3:34 PM
    hi guys, i'm pretty stuck with a small issue with the dashboard.. when I delete an user, I want to delete all it's own files in a bucket but I can't figure out how
    g
    • 2
    • 15
  • useUser causing infinite loop
    y

    YourAverageTechBro

    05/02/2023, 3:45 PM
    On my NextJS project I'm using the
    useUser
    function and it is causing my component to infinitely re-render. I've attached an image with an example component. I verified the loop by adding a
    console.log("hello")
    and when I comment out the
    useUser()
    call it does not loop infinitely but when I remove the comment it does cause an infinite loop. Is there something that I'm missing that is causing this infinite loop? I've never had this issue in other projects that I've used Supabase for.

    https://cdn.discordapp.com/attachments/1102984311818436651/1102984312732790944/Screenshot_2023-05-02_at_10.43.59_AM.png▾

    g
    • 2
    • 6
  • Error: ERROR: schema "pgtle" already exists
    g

    Grantly

    05/02/2023, 3:57 PM
    I am trying to run Supabase locally with the CLI. I have the latest version of the CLI. I am not sure what to do. I have searched the web for this error and I can't find any documentation around it. Thank you in advance for any help 🙂
  • supabase A few basic questions
    u

    클로버

    05/02/2023, 4:30 PM
    Originally I didn't use db, but I'm using supabase for the first time. studied for a week 1. If you look at the usage, if you do not create a schema, the default value is set, so select 'public' as the schema. There are other schemas, and it seems that you can put an arbitrary schema into the database with a command, but I don't think this is a recommended usage. Is it right? 2. I want to change the role given to a user. try to give more ratings The interface doesn't seem to be provided what to do Which roles are already designed for use? 2-1. I tested it manually When an anonymous connection matches anon, it is processed as anon. When I logged in, it seemed to treat it as authenticated if the address was the same as the preset address. I figured it out manually. Is there a document that organizes this? 3. I want to speed up the logout cycle Do you have logout logic? If not, should I just clear local storage and cookies?
    g
    • 2
    • 1
  • Trying to do a check before inserting or updating
    h

    Hugos

    05/02/2023, 4:42 PM
    Copy code
    sql
    CREATE OR REPLACE FUNCTION check_duplicate_product() RETURNS TRIGGER AS $$
    BEGIN
      IF EXISTS (
        SELECT 1 FROM products WHERE name = NEW.name AND size = NEW.size AND (id IS DISTINCT FROM NEW.id)
      ) THEN
        RAISE EXCEPTION 'Product with same name and size already exists';
      ELSE
        RETURN NEW;
      END IF;
    END;
    $$ LANGUAGE plpgsql;
    
    CREATE TRIGGER check_duplicate_product_trigger
    BEFORE INSERT OR UPDATE ON public.products
    FOR EACH ROW
    EXECUTE FUNCTION check_duplicate_product();
    Basically what I want is when a new Product row is inserted I want to verify that the name and size arent the same as any other row So if my existing table has a product with name: 'test' and size: 'small' The function should trigger when another product is insert where the name is 'test' and the size is 'small' if any of these 2 do not match, then there shouldn't be any exception. When I tested my above sql it does create the function and trigger but does not raise an exception when I tried to raise one by giving a duplicate record (except id)
    g
    • 2
    • 12
  • Duplicated columns that only occur on Production DB
    d

    Defhunt

    05/02/2023, 4:58 PM
    Hey fam. I think I have found a bug. On my Develop & Production (Not on my Local Development Environment) db environment the following is occurring. There are a few duplicate columns on my profile table which can only be seen in the Database view of the dashboard. However, there are no duplicate columns in the Table Editor. This is causing the issue of duplicate keys & value for when I run
    npx supabase gen types typescript --project-id \"SOME_ID\" > src/types/supabase-types.ts
    Is there a way I can resolve this?

    https://cdn.discordapp.com/attachments/1103002660015198260/1103002660380098610/Screenshot_2023-05-02_at_12.38.43_PM.png▾

    https://cdn.discordapp.com/attachments/1103002660015198260/1103002660740812810/Screenshot_2023-05-02_at_12.30.13_PM.png▾

    g
    • 2
    • 12
  • Frequent OTP issues, customers getting 401 across multiple browsers
    a

    altryne

    05/02/2023, 5:09 PM
    Hi, I'm at a wits end here. I've implemented auth a while ago, and randomly customers would copmlain about OTP not working for them. For me it works every time I try. Recently on a customer call someone was trying to register and it failed for them. and today someone reach out, claiming they tried 3 times from different browsers etc. I've reached out to support, they claimed this could be because I've added the URL to the email, some clients prefetch the link. I've since then created a JS redirect. So it can't be that the OTP is invalidated. I would love any ideas of how I could even test this please. Versions of packages
    Copy code
    ├─┬ @nuxtjs/supabase@0.3.5
    │ ├─┬ @supabase/supabase-js@2.13.1
    │ │ ├── @supabase/functions-js@2.1.1
    │ │ ├── @supabase/gotrue-js@2.24.0
    │ │ ├── @supabase/postgrest-js@1.6.0
    │ │ ├── @supabase/realtime-js@2.7.2
    │ │ ├── @supabase/storage-js@2.5.1
    Implementation: Code that sends the OTP (and magic link)
    Copy code
    const { error } = await supabase.auth.signInWithOtp(
        { email: email },
        {
          redirectTo: `${window.location.origin}${redirect || '/dashboard'}`
        })
    Code that verifies (and fails) when user enters it
    Copy code
    const { data, error } = await supabase.auth.verifyOtp({ email: otpModalOptions.value.email, token: code.value, type: 'magiclink'})
      if (error){
        code.value = ''
        errorOtp.value = true

    https://cdn.discordapp.com/attachments/1103005267899195392/1103005268138266705/CleanShot_2023-05-02_at_10.36.032x.png▾

    https://cdn.discordapp.com/attachments/1103005267899195392/1103005268566081606/CleanShot_2023-05-02_at_10.22.362x.png▾

    https://cdn.discordapp.com/attachments/1103005267899195392/1103005268889051207/CleanShot_2023-05-02_at_11.04.542x.png▾

    https://cdn.discordapp.com/attachments/1103005267899195392/1103005269270728755/image.png▾

    g
    • 2
    • 23
  • How to use an array of strings with iLike. Is it possible?
    d

    draco

    05/02/2023, 5:23 PM
    Is there a way to filter using an array of strings with the
    .ilike
    function from js? I know that i can accomplish it with sql if I do something like the following
    select * from some_table where column ilike all(array['val_1', 'val_2'])
    what I want to do is something like the following
    supabase.from('some_table').select().ilike('column', '%['val_1', 'val_2']%')
    Is this possible or would I have to us
    .or()
    and do lots of string concatenations for each element in an array to look like
    column.ilike.${array_entry_value}
    What I am trying to achieve is to do a case insensitive search for multiple text values in a table. If I use a filter like
    .in()
    it will do exact matches, but that is not ideal so
    ilike
    is the best option
    g
    l
    • 3
    • 10
  • Middleware config for protected pages (Next13 App Dir) ?
    m

    MusashiGarami

    05/02/2023, 5:29 PM
    The supabase docs (https://supabase.com/docs/guides/auth/auth-helpers/nextjs-server-components) gives an example for middleware but doesn't have any redirect logic in it. Does someone have a good example of middleware for the Next App dir that contains standard (if user authenticated continue, else bounce to home page)? I see the Next Pages example has middleware with this, but I'm not sure if that's best practice for App dir. I'm assuming there will be a very standardized best practice for not letting unauthorized users wonder around your app.
    t
    r
    j
    • 4
    • 13
  • Does Supabase-py lack async support? And what is the best practice for async calls in Python?
    m

    Muspi Merol

    05/02/2023, 5:41 PM
    I have been reading Supabase-py's docs for a while and I noticed that it doesn't seem to have async support. I am wondering if this is true and if so, why? Additionally, what are some recommended approaches for making async calls to Supabase in Python?
    k
    • 2
    • 1
  • trying to update a column
    m

    malphine2

    05/02/2023, 5:43 PM
    Not sure whats going on here, await supabase .from('company') .update({'schedule': schedule}); ive made sure that there is a schedule column in the company table but i am getting this error, PostgrestException(message: , code: 404, details: Not Found, hint: null). Any ideas?
    g
    • 2
    • 71
  • Automatic Database Migrations & Edge Function deployment on Selfhosted
    t

    turulix

    05/02/2023, 6:04 PM
    I saw the Management API isn't available at all on the self hosted version. Is it possible to work around this issue, and use a GitHub action to automatically deploy migrations aswell as Edge Functions?
    s
    v
    • 3
    • 17
  • trying to accept an invite
    s

    Someone.

    05/02/2023, 6:33 PM
    I'm trying to accept an invite but it redirects me to a localhost with this path:
    http://localhost:3000/#access_token=[token]&expires_in=3600&refresh_token=[token]&token_type=bearer&type=invite
    g
    • 2
    • 16
  • Why when i sign in using signinwithoauth() it creates a new user in Authentication Users ?
    c

    crimsen

    05/02/2023, 7:20 PM
    You can see the user created in authentication from the screenshot, and i guess signin method should not create users that does not exists

    https://cdn.discordapp.com/attachments/1103038214228410368/1103038214341660672/disshot.png▾

    g
    • 2
    • 7
  • iOS Auth: What is the use of the signOut() function?
    m

    malachi

    05/02/2023, 7:40 PM
    A quick summary of my current setup: When a user signs up or logs into the app I save the access token and refresh token in the iOS native keychain, then to not require the user to login again after every relaunch, every time the user launches the app I call the setSession() function, inputting the access and refresh tokens from the keychain in the function call, then using the returned session to update the tokens in the keychain. When I use the sign out function I assumed it would invalidate the existing tokens and require a new sign in to get new tokens but it does not seem to do this, as the setSession() still validates the session with the old tokens after calling signOut(). So what exactly is the signOut() function supposed to do? I am not sure if I am misunderstanding the use case of signOut(), setSession() or both here. Any clarifications would be greatly appreciated.
    g
    • 2
    • 3
  • Server side auth for nextjs / api
    n

    nickbryant.fyi

    05/02/2023, 8:31 PM
    Trying to access user session from a nextjs api endpoint. Not sure how to actually make it work. Would really appreciate a quick bit of insight.
    Copy code
    // Define the API route handler
    export default async (req, res) => {
      // Check if the request method is POST
      if (req.method === 'POST') {
        // Extract the message from the request body
        const { message, chatHistory } = req.body;
        const supabaseServerClient = createServerSupabaseClient<Database>({
          req,
          res,
        });
        const {
          data: { session },
        } = await supabaseServerClient.auth.getSession();
    
        const {
          data: { user },
        } = await supabaseServerClient.auth.getUser();
    
        console.log('session', session, 'user', user);
    This is how I'm invoking the nextjs API:
    Copy code
    import { supabase } from 'lib/Store';
    
    export const apiCall = async (endpoint, method, payload) => {
      const session = await supabase.auth.getSession();
      const options = {
        method: method.toUpperCase(),
        headers: {
          'Content-Type': 'application/json',
          Authorization: `Bearer ${session.data.session.access_token}`,
        },
        body: '',
      };
      console.log
    
      if (payload) {
        options.body = JSON.stringify(payload);
      }
    
      const response = await fetch(endpoint, options);
      const data = await response.json();
      return data;
    };
    
    export default apiCall;
    Working based off of the slack clone starter.
  • I'm getting errors even when wrapped in a try catch
    b

    BinaryBench

    05/02/2023, 9:02 PM
    This is the bit of code, basically I'm trying to query the user's profile if it exists & if it doesn't that redirect them to the
    /register-form
    , unless I'm already on the
    /register-form
    page: This works, however it still logs
    PGRST116
    errors to the console:
    Copy code
    javascript
    try {
      const { data: profile, error } = await supabase
        .from('profiles')
        .select('*')
        .eq('id', userResponse.data.user.id)
        .single();
      if (error) {
        throw error;
      }
      return profile;
    } catch (e) {
      if (e.code && e.code == 'PGRST116') {
        if (pathname !== '/register-form') {
          router.push('/register-form');
        }
        return null;
      }
      throw e;
    }
    What am I doing wrong here?
    g
    • 2
    • 1
  • Why i still see this xxxxx.supabase.co ?
    c

    crimsen

    05/02/2023, 9:18 PM

    https://cdn.discordapp.com/attachments/1103067987935776830/1103067988141277184/s1.png▾

    https://cdn.discordapp.com/attachments/1103067987935776830/1103067988481028197/s2.png▾

    s
    • 2
    • 1
  • Assume user from service role on edge function
    h

    hko

    05/02/2023, 10:13 PM
    Hi, I have an edge function that is being invoked as a webhook from a third party service (GCP). In the payload of the request, the email address of a supabase user is provided. I now would like to run database requests assuming the user as identified via the email address, so that RLS gets respected, e.g. Webhook payload:
    Copy code
    {
      "email": "iamasupabase@user.com"
    }
    and then do something like
    Copy code
    supabaseServiceRole.from("user_emails").select("user_id").eq("email":email)
    
    supabaseServiceRole.assumeRole(user_id);
    
    // continue requests in the same way as if coming from the logged in client
    It seems like most solutions I found rely on a JWT being passed, but I cannot do that.
    g
    • 2
    • 3
  • SelfHost Instant Login
    h

    Hexi

    05/02/2023, 10:15 PM
    My selfhosted supabase db works alright but when I go to the supabase website I see for a split second the login and the get logged in but I want it so I can host my supabase url on my domain and dont want anyone to access it
    s
    • 2
    • 6
  • getSession() returns null data
    k

    KiwiHour

    05/02/2023, 10:50 PM
    Logging in isn't working When checking the accounts after I login, it shows that I last signed in at the correct time. So I know that the signing in is working fine. But I cannot get sessions I know I needed to use
    getSession()
    instead of
    getUser()
    , but that was returning null too. So I used
    setSession()
    The session I use to set it has valid information in, but the next line i get the session to check its been set, and its null again. Whats going wrong?

    https://cdn.discordapp.com/attachments/1103091216654028861/1103091216784031974/image.png▾

    https://cdn.discordapp.com/attachments/1103091216654028861/1103091217065054208/image.png▾

    g
    • 2
    • 6
1...199200201...230Latest