https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Supabase realtime while using Prisma
    f

    Fayyaz

    03/06/2023, 1:07 PM
    I am wondering if I use Prisma, can I still use supabase realtime?
    t
    b
    • 3
    • 2
  • Query join data with supabase cli
    v

    Vimes

    03/06/2023, 1:13 PM
    Trying to query "nested" foreign key data for profiles, but not sure how I can create such a query. The table profiles has an organization connected via FK to an org table. Different orgs have access to different things. I want my query to go something like this "Logged inn user -> Organization -> Projects -> Hours spend", all of these are their own tables. The only way the current user us connected to projects and hours spent is through the FK from profiles -> organization. So somehow I need to auth that users can get this data and only the data for their own org, admins can get all data (admin status is set up profiles table). Using nextjs with supabase.js
    • 1
    • 1
  • Password reset security question
    t

    tom-s3drive

    03/06/2023, 1:47 PM
    When password reset is requested, Supabase will send a magic link to a user's e-mail, which upon clicking logs user in, but not necessarily enforces that user actually do reset their password. I am implementing password/e-mail auth system (https://supabase.com/docs/guides/auth/auth-email), but reset password feature technically is security downgrade to Magic link (https://supabase.com/docs/guides/auth/auth-magic-link) Is there any possibility of preventing user's from using reset password feature as Magic links?
    s
    • 2
    • 6
  • Is it possible for dynamically creating a user without Email Signup
    b

    Biondi Bagasta Wiko Putra

    03/06/2023, 1:51 PM
    I'm creating an IONIC - Angular which there are so many user can login to the system. Since Supabase Auth Email Sign Up should use email verifiaction / email Sign Up, is it possible to make it without Supabase Auth and use the custom table instead maybe with some Hashed Password on password column...
    g
    • 2
    • 1
  • Listen to realtime changes in a storage bucket
    a

    AdamJensen

    03/06/2023, 1:58 PM
    Creating a feature in my app for realtime document editing, where multiple users can work on a document simultaneously, similarly to Google Docs, Dropbox Paper etc. Just wondering how that can be done with Supabase Realtime and Supabase storage, since I don't want to be pulling the whole file on every single change. If it's possible to live stream those changes through some realtime channel that would be great (and not having to reflect changes to the whole file), however if someone has done this before, some guidance is much appreciated 😄
    g
    • 2
    • 3
  • Regarding Table Editor
    a

    Abku

    03/06/2023, 2:11 PM
    I already freeze the column, but it's keep getting arrange automatically. Is there any other change I should make?
    g
    • 2
    • 12
  • RLS with a Key
    o

    Oskarsh

    03/06/2023, 2:16 PM
    Hey I am building a system where I am running a GitHub action that is populating my supabase DB. I want to create a RLS policy that only allows the GitHub action to create new data in my table. What is the best way to authenticate my python script running inside the gh action against supabase? Since this gh action has no account I cannot use the normal authentication and would like to use a secret key to authenticate. Is this possible?
    g
    • 2
    • 4
  • User metadata and signInWithOAuth
    v

    Val

    03/06/2023, 3:09 PM
    Hello everyone, After going through the documentation and my tests, it seems to me tha**t it isn't possible to pass custom user metadata while using the signInWithOAuth() function** with a provider such as google. Can someone confirm this fact please ? My problematic being : I have 2 different URL, which both choice email and google auth. One is the classic login/signup page for the app. One is a temporary signup page for an event with a promotion (3 months trial for example). I am currently able to pass different value for the meta data to the user signing up, for example trial_activated = false / true depending on the source. I am currently able to retrieve this metadata in a **function **on the supabase side after using a **trigger **on_user_created. My problem is, this is a "custom" metadata, so supabase can't access it when creating a user with google auth, and so I'm stucked. **TLDR : I'm able to pass custom metadata to new user when they're signing up by mail, but I can't do it for external providers. Did I miss something ?** PS : btw I'm working with Sveltekit so I'm using @supabase/auth-helpers-sveltekit Thanks a lot
    g
    • 2
    • 6
  • Nextjs supabase-server error within api/route?
    h

    homyak

    03/06/2023, 3:38 PM
    When I
    import { createClient } from '@/utils/supabase-server
    into an api route I am receiving the error below, but when I use
    supabase-browser
    I do not get any errors. If the API routes are always executed on the Nextjs server, why should I have to use the supabase browser client provided by
    createBrowserSupabaseClient
    ? I am attempting to register a user within an API route in order to perform other user initialization tasks upon user creation, rather than calling
    signUp
    from within a client component.
    Copy code
    // api/register/route.js
    
    import { createClient } from '@/utils/supabase-server' // Error in terminal
    
    export async function POST (request) {
      const supabase = createClient()
    
      const { data, error } = await supabase.auth.signUp({
        email: 'example@example.com',
        password: 'password',
      })
    
      return Response.json(data)
    
    
    }
    Copy code
    bash
    Import trace for requested module:
    ./node_modules/node-fetch/lib/index.js
    ./node_modules/cross-fetch/dist/node-ponyfill.js
    ./node_modules/@supabase/supabase-js/dist/main/lib/fetch.js
    ./node_modules/@supabase/supabase-js/dist/main/SupabaseClient.js
    ./node_modules/@supabase/supabase-js/dist/main/index.js
    ./node_modules/@supabase/auth-helpers-shared/dist/index.js
    ./node_modules/@supabase/auth-helpers-nextjs/dist/index.js
    ./utils/supabase-server.js
    ./app/layout.js
    
    
    ./node_modules/node-fetch/lib/index.js
    Module not found: Can't resolve 'encoding' in '/Users/homyak/development/personal/authentication-template-supabase/node_modules/node-fetch/lib'
    
    Import trace for requested module:
    ./node_modules/node-fetch/lib/index.js
    ./node_modules/cross-fetch/dist/node-ponyfill.js
    ./node_modules/@supabase/supabase-js/dist/main/lib/fetch.js
    ./node_modules/@supabase/supabase-js/dist/main/SupabaseClient.js
    ./node_modules/@supabase/supabase-js/dist/main/index.js
    ./node_modules/@supabase/auth-helpers-shared/dist/index.js
    ./node_modules/@supabase/auth-helpers-nextjs/dist/index.js
    ./utils/supabase-browser.js
    ./components/login-button.jsx
    • 1
    • 1
  • Purpose of middleware in NextJs
    m

    Madses

    03/06/2023, 3:59 PM
    I just finished watching this new video

    https://www.youtube.com/watch?v=Bh1TOpOcGJQ▾

    , great stuff. A statement made in the video was made "The reason we need middleware is because cookies in NextJS are read only". The middleware in question is attached as an image below. The code in question does not really set any cookies, I'm just curious what the middleware is for and what it's actually doing under the hood. Just some insights as to why this is needed would be great. Right now its not really clear for me what this middleware is for. Thank you in advance.
    n
    • 2
    • 2
  • RLS disabled for tables in auth schema?
    s

    stevecaldwell

    03/06/2023, 4:00 PM
    I'm managing schemas in Prisma, and this seemed odd. Just want to verify that this is correct default behavior.
    g
    • 2
    • 1
  • Order of operation for RLS policy and trigger execution?
    b

    brassotron

    03/06/2023, 4:58 PM
    Hello, I'm having a bit of an issue with selecting an inserted row when triggers are enabled. I'm adding teams for which I have two tables,
    teams
    and
    team_members
    . The teams table only has a
    name
    column and team_members has only
    team_id
    and
    user_id
    columns. Teams has an insert RLS policy that allows any authenticated user to insert a team with a given name. A trigger is then executed AFTER INSERT on teams and will insert a row into team_members with the
    id
    of the inserted team (
    team_id
    ) and the current auth.uid() (
    user_id
    ); If I add an RLS policy to the teams table to only allow SELECT on teams you're a member of;
    Copy code
    sql
    exists (
      select * from team_members where team_members.team_id = teams.id and team_members.user_id = auth.uid()
    )
    This fails with the following JavaScript snippet due to an RLS failure for teams.
    Copy code
    ts
    const { error, data } = await supabase.from('teams').insert({ name }).select('*');
    However, if I use the following JavaScript instead, it works as expected.
    Copy code
    ts
    const { error } = await supabase.from('teams').insert({ name });
    
    const { error, data } = await supabase.from('teams').select('*');
    
    console.log(data) // contains the created team
    I expect this is due to the order of operation that the RLS policy is evaluated and the trigger executes? In that in the first snippet at the point the select is executed the trigger has yet to insert the
    team_member
    row and therefore fails? Thanks for any help! Connor
    g
    • 2
    • 25
  • Can I Use SQL Editor For Custom Policies?
    c

    COLD1

    03/06/2023, 5:09 PM
    I would like to know if I can use the SQL editor to create my own policies as well as roles and foreign keys etc..? I noticed that there are shortcuts built-in however I would like to use the editor, and if I use it, will I be missing out on anything critical (like JWT, etc.. )?
    g
    • 2
    • 20
  • Can I add a TTL to my supabase storage?
    l

    leif

    03/06/2023, 5:29 PM
    I want to use the supabase storage as a temporary place to store user uploaded files. Is there a way to auto delete files after a specific amount of time?
  • API and Auto Increment Primary Key
    e

    enti

    03/06/2023, 5:38 PM
    I got a table with an
    id
    column, which is an Auto Increment Primary Key. I want to
    upsert
    many values at once, with somes existing, somes not.
    Copy code
    json
    [
      {
        "id": 611,
        "answer": "answerOld",
      }, {
        "answer": "answerNew",
      }
    ]
    The
    upsert
    API call gives me this response : "All object keys must match"
    id
    not being provided for the new entry while it is for the old entries seems to be a problem for some reasons. The postgres doc offers a
    DEFAULT
    keyword which can't apply in javascript. I can't find a way to specify a default incremental value for
    id
    through an API call around the supabase doc. How could I resolve that problem without making 2 API calls, which wouldn't really be the best option?
    g
    • 2
    • 17
  • Problem uploading to bucket - HTTP response 400
    c

    chrtravels

    03/06/2023, 5:46 PM
    Hi all, Just using the function, to upload to a public bucket, per the docs:
    Copy code
    const avatarFile = event.target.files[0]
    const { data, error } = await supabase
      .storage
      .from('bucketName')
      .upload('public/avatar1.png', avatarFile, {
        cacheControl: '3600',
        upsert: false
      })
    The problem is, the URL, for images stored in this bucket look like: /storage/v1/object/**public/banner-images**/test.png but using the function above you get: /storage/v1/object/**banner-images/public**/test.png So "public" should come before the bucket name. It's possible the URL to post images in the bucket should be different but we don't actually know what it should look like since this is all done through these supabase functions.
    g
    • 2
    • 2
  • supabase auth in nextjs
    j

    just9inches

    03/06/2023, 5:55 PM
    logout not working or not redirecting to login page
    g
    s
    • 3
    • 22
  • How to diagnose RLS?
    n

    nateland

    03/06/2023, 6:00 PM
    I have an extremely simple RLS for one of my tables that isn't letting me access the data. I'm not sure what I'm doing incorrectly... how can I diagnose this?
    g
    • 2
    • 13
  • _app Root Next.js Subscriptions
    m

    mjs

    03/06/2023, 6:15 PM
    Hi, I was wondering has anyone been challenged with using multiple useEffect based subscriptions in their Next.js apps. I've got a listener for updates to a table in my _app.tsx root of a Next.js app, but it's super verbose. To create multiple useEffect Supabase JS subscriptions to listen for changes at a root level, I'm probably going to end up with an enormous app file if I don't make some of them hooks, which even at that feels pretty unnecessary. Does anyone know if you can listen for all changes, once - and somehow determine what was made after the fact? Or any other helpful tips for this kind of architecture Cheers
  • Database table that updates daily at 3pm?
    k

    kevlust

    03/06/2023, 6:57 PM
    I'm building a social app on iOS, where I want to feature a daily quote. I want that quote to change for everyone at the same time (say 3pm eastern) to ensure everyone is always looking at the same one. How can I leverage the tools provided by Supabase to solve this? Here's what I'm thinking: maybe I can have a private database table of quotes, and a public one. On the private one, I keep all of the ones that I'm planning on using in the future, with a simple Int index. Then, I set up some function that runs everyday at the same time and pulls the quote with the lowest index from the private table, and adds it to the public one. That way, the public one is always up to date (without revealing future quotes). Is that the best approach? If so (assuming it's possible), how could I make it work? Are there any examples of similar solutions that I could use as an example for my use case? Thanks in advance!
    g
    • 2
    • 4
  • Losing session on refresh
    c

    chrtravels

    03/06/2023, 7:11 PM
    I am new to NextJS and Supabase, so this is possibly a NextJS issue, I'm not positive. I seem to lose the session upon page refresh. Sometimes I will refresh the page and the session will be there in console.log, sometimes it's null. So when it's null, the data I get from the session doesn't load on the page. Wondering if I should be loading the session in local memory or if there is a way to get a more stable session. I am wrapping _app.js in the SessonContextProvider and passing in the session and then use useUser() to get the logged in user, on the pages I need it. For my profile page, I then query the database for the matching profile and return the data to load the profile image, banner, etc...Half the time I end up just seeing the placeholder images. Any direction is appreciated. 🙂
    a
    • 2
    • 11
  • Deleting key field from jsonb column
    b

    Bizzare

    03/06/2023, 7:28 PM
    Hi, I have a column ("characteristics") in my table which is defined as jsonb type with the following example
    Copy code
    structure:
    {
      "color": {
        "value": "red"
      },
      "dimension": {
        "value": "100x100"
      }
    }
    I want to be able to delete the whole key "color" for example. If I'm doing the following: `async delete_characteristic(name, row_id) { const { data, error } = await supabase.from('table_name') .delete() .eq('characteristic_id', row_id) .eq(
    characteristics->${name}
    , name) .select(); }` I get an error with message: 'invalid input syntax for type json' for the "name". I ended up extracting the whole column value and updating it after performing a delete(name) on the JS object, but I was wondering if I can achive the same with supabase.from().delete(). Thank you!
    g
    • 2
    • 2
  • I cannot make this joined tables work like shown on the supabase video
    g

    goldyman

    03/06/2023, 9:17 PM

    https://www.youtube.com/watch?v=5RoCKuJaYPU▾

    In the situation of the many to many relationship. I have table "gifts" and a table "tags", I have a "gifts_tags" table in between with following the same naming logic as from the video. I get an exception in flutter saying "Searched for a foreign key relationship between 'gifts' and 'tags' in the schema 'public', but no matches were found." my request is looking like this
    Copy code
    dart
    final map = gift.toJson();
          final userId = _supabaseClient.auth.currentUser!.id;
    
          final result = await _supabaseClient.from('gifts').insert({
            'description': gift.description,
            'owner': userId,
            'latitude': gift.latitude,
            'longitude': gift.longitude,
            'colors': map['colors']
          }).select<Map<String, dynamic>>(
            '''
            *,
            users(id, email, username, birthday, created_at, hasAvatar),
            tags(*)
            ''',
          );
    I the specific case I don't have any tags attached yet. the insert request is later in the flow. Is it possible that it is throwing because there are not tags yet?
    g
    • 2
    • 1
  • Connecting to Default Project - Local dev
    h

    Hallidayo

    03/06/2023, 9:21 PM
    When running Supabase locally with the most recent pull on the main repository on http://localhost:8082 for local development their seems to be an issue when the project does not connect. When checking the console it seems requests to 'rest' are causing the issue? The requested URL is: http://localhost:8082/api/projects/default/api/rest which does not exist. Is anyone else experiencing this?
    i
    • 2
    • 2
  • Purge logs?
    h

    hko

    03/06/2023, 9:24 PM
    Is there a way to easily purge the logs of edge functions?
  • "No filters for this update query" in supabase dashboard?
    y

    yayza_

    03/06/2023, 9:26 PM
    I'm trying to create a new column id and preset the null values so that i can change it to an identity later, when I do it I get:
    no filters for this update query
    I was wondering what that means
    g
    • 2
    • 9
  • Are stored procedures not included in Supabase generated types?
    d

    DYELbrah

    03/06/2023, 9:38 PM
    I created a stored procedure using:
    Copy code
    CREATE PROCEDURE saveTransactionSP(
       IN transaction_id INTEGER,
       IN transaction_line_items TRANSACTION_LINE_ITEM_IN[],
       IN full_length_stock_picks FULL_LENGTH_STOCK_PICK_IN[],
    .....
    I then generated my supabase types and noticed that the procedure isn't anywhere on the generated types.
  • Wanting to use Supabase for Swift App
    t

    tincan

    03/06/2023, 9:45 PM
    I am just reaching out to see if it is possible to use Supabase for a production swift application. I will need to make users, so auth and I am also wanting to also save images. If this is possible and someone is able to point me in the right direction for me to get started that would be excellent! Thank you for your time and have a great day!
    g
    g
    l
    • 4
    • 140
  • pg_execute_server_program / superuser
    z

    zachblume

    03/06/2023, 10:09 PM
    From backend I am executing a query: COPY donations(...columns...) FROM PROGRAM 'curl "URL/file.csv"' DELIMITER ',' CSV HEADER; ...which of course loads a csv through STDIN into the native PG COPY loading program. However, running this query requires the role pg_execute_server_program and I cannot execute GRANT pg_execute_server_program to postgres; Because => no superuser access. Any way around this, or should I contact support for this role?
    g
    • 2
    • 26
  • Permanent Test User Email OTP
    r

    robertn702

    03/06/2023, 10:10 PM
    I am using email OTP for my mobile app, which needs a predictable OTP in order to be reviewed in the App Store. I was previously using a workaround[0] which stopped working after having my Supabase instance upgraded (Now receive
    AuthApiError: Token has expired or is invalid
    error). I assume this is due to changes made in
    @supabase/gotrue
    . Does anyone know if there is a similar workaround? I have tried manually setting the
    recovery_token
    ,
    reauthentication_token
    , and their respective
    sent_at
    values, with no luck. [0]: https://github.com/supabase/supabase/discussions/5358#discussioncomment-4704569
    c
    • 2
    • 1
1...156157158...230Latest