https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Slow API response
    r

    rbkayz

    10/31/2022, 9:22 PM
    Hello community, Facing an issue with an RPC function. I've checked the function performance thoroughly using explain analyze. It takes <70ms for the function to execute. However, the API response takes more than 5 sec. And there isn't a lot of data being transferred - I removed all the data in the response and it still takes over 5 sec Any idea why this might be happening? Or a solve for it? Thanks
    g
    p
    • 3
    • 8
  • Returning null after data inserted into table
    t

    tEjAs

    10/31/2022, 9:51 PM
    Hello, I have a table that I am inserting data into with await tableName.insert(data) and this works fine. However, when I then try to execute a select query with const {data, error} = tableName.select() I get null. When I restart my server (express, node JS, running on localhost) I can access the data until I insert something else again and get null. Can someone help me with this? Thank you.
    g
    • 2
    • 9
  • Magic links only work only if user exists?
    c

    Cheqo

    10/31/2022, 10:01 PM
    Hi, I am trying to implement sign in with OTP using this:
    Copy code
    const handleOtpVerify = async () => {
        const { data, error } = await supabaseClient.auth.verifyOtp({
          email,
          token: otp,
          type: 'magiclink'
        });
    It works perfectly with existing users, however, if user doesn't exist he will receive confirm your signup email(see the screenshot)? Why? Does that mean that I need to have 2 UI screens/pages - one for Create account other for Sign in with email? Is it possible to handle this logic somehow with one email input field?
    j
    g
    • 3
    • 11
  • Supabase with ReactJS and Prisma
    w

    Walid

    10/31/2022, 11:49 PM
    Hi everyone i'm using Supabase with prisma in a React project (no SSR). and as we know, to configure prisma we put the link of postgress in the .env file , and this link contains the DB connection information. is it secure to use prisma in this case ? and how to protect the DB in this case ? thanks a lot
    j
    j
    n
    • 4
    • 9
  • How to query a table by multiple columns
    b

    benyi3k

    11/01/2022, 2:07 AM
    I have an Orders table where I need to query the same value over to columns (title and description). How can I do that with Superbase javascript client?! Thanks in advance.
    g
    • 2
    • 20
  • How to get initialSession to work with SSR
    c

    Cody

    11/01/2022, 3:04 AM
    Greetings, I went through the basic setup for Auth and Next.js and found that
    initialSession
    on
    pageProps
    is never populated. What do I need to do to make it so the session is used in SSR so that there is not a flash of content with the login page before quickly flipping to the Account page?
    • 1
    • 1
  • Can't Create Project
    u

    <br/>

    11/01/2022, 3:10 AM
    Hi, i'm new to Supabase. Just registered today and I'm trying to create a project but it said error everytime I hit create project button. Also, there's an error on organization page (i have Owner role).
    • 1
    • 1
  • bucket metadata
    u

    ((()))

    11/01/2022, 7:37 AM
    Is it possible to add custom data into bucket -> object metadata similar to auth.user metadata?
    b
    • 2
    • 1
  • Supabase returns unknown error message as HTML
    g

    Greg

    11/01/2022, 9:24 AM
    Every few days I get a random dump of HTML in my Node.js logs and it seems to be a Supabase error message. The is
    qlznxajtjhrqwebbryiu.supabase.co | 520: Web server is returning an unknown error
    It's a bit tricky to handle errors when returned as HTML 😅 so I'm wondering if this is a known bug / if there's a better way for me to handle it / if there are common known causes for 520 errors?
  • SOLVED IT, how do i delete this? XD
    b

    Bamsespartymix

    11/01/2022, 12:24 PM
    ✅
  • BUG - SQL data based on project name
    t

    talpiven

    11/01/2022, 11:44 AM
    Renaming project disappearing all SQL editor function , I think the problem is that we get the data based on name of project and not kind of id, because when I rename it back to the original name it appears again
  • Multiple RLS Policies
    u

    49Ryann

    11/01/2022, 12:11 PM
    I have a contacts table with two polices, - one with an organisation_id check - two with a user_role check I have tested that both of these work individually, but combined I guess it always gets a true with the organisation check and will load the data ignoring the role check. Is this normal behaviour? I would like this to do the checks and if one returns false then it won't load the data, Or do i have to combine these into one Policy ?
    g
    • 2
    • 2
  • Next.js protect login page from authenticated users
    n

    noahflk

    11/01/2022, 1:14 PM
    I want to redirect logged in users back to the application when they visit the login page. I used to be able to call
    const { user } = await getUser(ctx);
    from gSSP but that's no longer possible. How can I achieve this with the latest version?
    g
    • 2
    • 1
  • is this correct supabase call - supabase.from('users').select('*').single() ?
    l

    Lukas V

    11/01/2022, 1:49 PM
    I am looking at supabase stripe starter template code and I'm trying to figure is this correct call? https://github.com/vercel/nextjs-subscription-payments/blob/main/utils/useUser.tsx
    Copy code
    const getUserDetails = () => supabase.from('users').select('*').single();
    This supposed to retrieve currently logged in users public row in database, but I don't see
    uid
    being passed anywhere, it literally reads like this: get me first user in users table instead of *get me single user row that matches this uid* is this a mistake or actually correct call somehow?
    g
    • 2
    • 1
  • Protecting routes with Nextjs Middleware
    i

    ismael1234

    11/01/2022, 3:10 PM
    I tried adding this code from supabase website:
    Copy code
    import { withMiddlewareAuth } from '@supabase/auth-helpers-nextjs'
    
    export const middleware = withMiddlewareAuth({ redirectTo: '/login' })
    
    export const config = {
      matcher: ['/middleware-protected/:path*'],
    }
    in the file "middleware.ts" inside pages, also tried after in "_middleware.ts", and doesn't work. In the first file it doesn't do anything, in the second one it gives me many errors. Changing /middleware-protected/:path* to "comments or /" for example doesn't do anything.
    s
    • 2
    • 1
  • Supabase realtime not always emitting
    b

    Brams

    11/01/2022, 3:44 PM
    Hello, I currently have a realtime listener to listen for insert / update events on a table. There is a postgres function which can be called through rpc and updates a row in this table. The listener appears to emit an event on the first time this happens, but when the function is called again through rpc, it does not appear to emit any events. Any ideas as to what might be causing this?
    g
    • 2
    • 9
  • Is there any way to generate an auth session without credentials?
    a

    Azura

    11/01/2022, 5:28 PM
    Hi, I'm currently implementing a
    log in with QR code
    system and looking for a way to programmatically generate a new auth session to be used in a Next.js API route and pass it back to the other device that contains the QR code (the requesting device). Does supabase currently support this use case? If not, is there any known workaround? Thanks a lot!
  • a way to check if google user is new vs calculated guess
    d

    Domcario

    11/01/2022, 5:38 PM
    How can I check if a user that signed in via google oauth is a new user that just signed in for the first time? it's easy to track this when it's email/password login, but unsure for google signin users or should i just do a time comparison of the user's metadata. for ex: if
    supabase.auth.getUser().created_at
    is within 2 seconds of
    supabase.auth.getUser().last_sign_in_at
    then safe to assume it's a new user?
  • Database Relationship just returns null
    u

    UCDFiddes

    11/01/2022, 5:58 PM
    I have 2 tables one called cosmetics and one called models on my cosmetics table i have made a relationship on the column called model it has a uuid in it and is the same id as the primary key on the models table. When i use supabase-js to get the cosmetic table with the models it just returns null and i dont know whats wrong?
    g
    • 2
    • 6
  • “UPDATE requires a WHERE clause”
    s

    Smardrengr

    11/01/2022, 6:04 PM
    Even when I try to
    insert
    a row in a table that, FWIW, has a constraint on two columns, e.g.:
    Copy code
    create table players (
      id uuid primary key DEFAULT gen_random_uuid(),
      created_at timestamp with time zone default now(),
      updated_at timestamp with time zone,
      user_id uuid not null references auth.users,
      game_id uuid not null references games(id),
      num int default 0,
      unique(user_id, game_id)
    );
    supabaseClient returns the error
    Copy code
    {
      code: '21000',
      details: null,
      hint: null,
      message: 'UPDATE requires a WHERE clause'
    }
    Any ideas? (Upserting fails too the same way.)
    g
    • 2
    • 4
  • upsert creates duplicate entries with the same data
    t

    Thoth Trismegistus

    11/01/2022, 6:06 PM
    Copy code
    js
    await supabaseClient.from('trackings').upsert({
                user_id: $page.data.session?.user.id,
                data: "same"
            });
    this creates multiple entries
    j
    g
    • 3
    • 9
  • Trouble setting up Login with GitHub
    z

    zettabyte

    11/01/2022, 7:49 PM
    Currently following the supabase guide to set up a GitHub OAuth application: https://supabase.com/docs/guides/auth/auth-github. Under the section "Enter your GitHub credentials into your Supabase Project", I don't see anywhere in the supabase auth settings where I am supposed to input my
    Site URL
    ,
    GitHub Client ID
    , and
    GitHub Client Secret
    . Are these docs outdated? Or is this step no longer necessary?
    s
    • 2
    • 2
  • Next.js set state after insert, NULL issue
    g

    Gary

    11/01/2022, 7:58 PM
    Hi. I want to update state after inserting a new row, but when receiving the data value I get NULL instead of the entire array of data from the database. I couldn't find a v2 example of this so I have been following the next todolist example from v1 in the examples archive.
    Copy code
    js
            const [items, setItems] = React.useState(fetchItems, []);
    
        const addItem= async () => {
            let { data: item, error } = await supabase
                .from("TableName")
                .insert([{ user_id: user.id }])
                .single();
            if (error) setError(error.message);
            else setItems([...items, item]);
        };
    I can fix this by adding my fetch function after setItems, but it re-renders the entire list of items instead of just adding 1. Is there a way around that? Thanks very much.
    g
    • 2
    • 3
  • Help with a trigger
    s

    Smardrengr

    11/01/2022, 8:10 PM
    Not a trigger expert... I would like to sum the
    num
    of confirmed
    players
    in the
    games
    table each time a player record is created, updated or deleted. Here’s my non-working code:
    Copy code
    drop function if exists games_players cascade;
    
    create or replace function games_players()
    returns trigger as $$ begin
    update games set players_conf = (select sum(players.num) AS num from players where players.game_id = NEW.game_id group by players.game_id) where games.id = NEW.game_id;
    return NEW;
    end;
    $$ language plpgsql;
    Any ideas?
    g
    • 2
    • 7
  • Migrate or Copy DB from Project
    k

    Kelaos

    11/01/2022, 8:13 PM
    I see in #885237287280070708 there's no way to transfer ownership of a project. I'm only using the Database + API for Supabase for this client project. Do I have to manually recreate all the tables in the new Supabase instance they create or will dumping all the postgres tables into the Supabase DB be sufficient? Thanks!
    g
    • 2
    • 5
  • One Time Password with Email
    k

    konga

    11/01/2022, 8:49 PM
    How do I configure the email to display the One Time Password instead of a url?
    g
    • 2
    • 1
  • Postgres RLS user
    t

    turner

    11/01/2022, 9:00 PM
    I created a postgres user, but still I cannot add privileges to
    rls_user
    (neither from the SQL Editor in the dashboard) to read from my tables. the user can connect to the database, but a
    select * from table_name
    returns an empty array. is there any documentation on how to properly add a user to the supabase postgres db? has anyone had the same issue? I want a user to connect directly to the database instead of using supabase‘s postgRESR API. The user should be affected by RLS, I want to set the jwt claims at every session.
    s
    • 2
    • 1
  • Better controlling the returned response from a foreign table query
    i

    InASunshineState

    11/01/2022, 10:26 PM
    I have a table 'images' with various image-related information, a table 'favorites_folders' that is a simple listing of ids, folder names, and a column to denote if that folder has a parent folder ( which is simply an integer pointing back to the same table ) When I use Supabase to look for this:
    Copy code
    asset_data:images ( asset_id, height, metadata, public_id,tags, url,width),
            folder_data:favorites_folders ( folder_id:id, folder_name ),
            parent_folder_data:  favorites_folders  ( parent_folder_data:parent_id(parent_folder_id:id, parent_folder_name:folder_name) ) )
    It returns each row with an asset_data object, folder_data object and parent_folder_data object. I want it all sort of flat, like all the asset_data's individual properties like height, on the same nested level as folder_id, and also on the same level as parent_folder_id Right now I use map() in Javascript and spread through each to handle them differently, but I was wondering if there was a wiser/smarter query to get it right out of the gate flattened. The parent_id on favorites_folders is a foreign key relation to favorites_folders, and there's a table user_favorites which is the row ID and then a foreign key relation to the user table, and a foreign key relation from the stored asset_id there to the data it references in the images table.
    d
    • 2
    • 3
  • auth-ui-react not SSRing styles into the HTML
    c

    Cody

    11/01/2022, 10:30 PM
    This is quite odd, but when SSRing the
    <Auth />
    component from
    @supabase/auth-ui-react
    , the styles are not added to the HTML, so the component is initially not styled. That's not the weird part, though. The weird part is that once it is styled and a class name is added which points to a set of styles that don't actually exist inside the DOM. When you inspect the elements, check the styles, and click on their source, it redirects you to an empty
    <style></style>
    tag. I've never seen this before...
    s
    • 2
    • 3
  • Google Provider not respecting redirectedFrom query param
    c

    Cody

    11/01/2022, 10:43 PM
    When utilizing
    withMiddlewareAuth
    from
    @supabase/auth-helpers-nextjs
    , a
    redirectFrom
    param is provided so you can use it to redirect back to the protected page. When logging in via the Google provider, the parameter is lost on the way back. What is the best way to achieve the ability to redirect back to the previous page when logging in via Google?
    s
    • 2
    • 2
1...575859...230Latest