https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • supabase dashboard has no authentication
    b

    bobmolgui

    11/05/2022, 4:12 PM
    https://supabase.com/docs/guides/hosting/docker#securing-the-dashboard
  • for a many to many relationship with an auxiliary table, is there any cleaner way to insert data?
    i

    ismael1234

    11/05/2022, 3:25 PM
    I imagine I would need to make an insert method for data 1 with data 2, another call for data1 with data 3, etc in a foreach call. Is there any method like "data 1 with data [2,3]" in a single call?
    j
    • 2
    • 11
  • onConflict Python upsert
    g

    gtims123

    11/05/2022, 4:27 PM
    Is there an onConflict parameter for the Python supabase API’s upsert() function? I’ve been trying to use that parameter but it seems to not exist. Is the workaround to use the RESTFul supabase API in my Python code base?
    j
    g
    • 3
    • 7
  • Transaction (Rollback & Commit)
    l

    LeDragunov

    11/05/2022, 4:55 PM
    Hello all, I'm creating functions to perform multiple actions (Insert and delete) on tables. I'm afraid that some failure might take place while the function is in process, so is it recommended to use Rollback & commit in such scenario? I've tried my self and found out that the function is not committing unless all actions took place. But wanted to double check with you all if rollback and commit is necessary or not or supabase is already handling it. Thanks ❤️
    g
    • 2
    • 2
  • Using cookies vs localstorage
    n

    nish

    11/05/2022, 5:58 PM
    Sorry if this has been asked before. I wasn't able to find any information. I noticed that the session is sometimes stored in localStorage and sometimes in cookies. Is using the storageKey parameter in createClient the correct way to enforce localStorage usage? What is the correct way to enforce cookie usage, and set cookie name? Another related issue is that I am not seeing an option to clear the cookie / localStorage on signout. If the current session is valid the user can signout without an issue but if the token or session has expired signOut doesn't work leaving the user with a stale session he can't exit. Any ideas?
  • How do i fetch multiple images from supabase storage?
    s

    Shoaib

    11/05/2022, 7:51 PM
    Would really appreciate it if you could share some code snippets. FYI I'm building a flutter app
    g
    • 2
    • 1
  • [Auth-helpers] Issues with refresh token when extending JWT expiration
    k

    Karbust

    11/05/2022, 8:10 PM
    Hello, Disclaimer: I'm self-hosting Supabase. When I leave
    GOTRUE_JWT_EXP
    on the default value of 3600 I don't get any error, but if I extend it to like a month (2592000) I get the error in the screenshot while loading the session on the website. Do I need to change something else? Doing something like this also returns the same error every single time:
    Copy code
    ts
    setInterval(async () => {
        await supabase.auth.refreshSession()
    }, 1000)
    g
    • 2
    • 37
  • Remove current session (Flutter)
    s

    stefikira

    11/05/2022, 8:23 PM
    Is there a way to log out the user when a session is removed directly from the DB?
    client!.auth.currentSession
    still shows the user as logged in.
  • Next.js - useSession flickering
    s

    Solid Snake

    11/05/2022, 9:21 PM
    Hi, using a navbar in _app.js I experience flickering when the browser renders a page with an active session. I can see for a moment the wrong navbar. How can I fix that? _app.js
    Copy code
    <SessionContextProvider
          supabaseClient={supabaseClient}
          initialSession={pageProps.initialSession}
        >
          <Navigationbar />
          <Component {...pageProps} />
    </SessionContextProvider>
    navbar.js
    Copy code
    export default function Navigationbar() {
      const router = useRouter()
      const session = useSession()
      const currentPath = router.asPath
      if (!session) {
        return (
          <NavbarPresentation router={router} />
        )
      }
      else if (session)
        return (
          <NavbarLoggedIn router={router} />
        )
    }
    n
    d
    • 3
    • 4
  • auth table vs profiles table - which is recommended for FK referencing of UserID?
    u

    Unknown Member

    11/06/2022, 1:57 AM
    Hey guys, so since the auth/users table and the profiles table are separate, I am just wondering that if I have a table for listings (goods and services...), what is the recommendation when making a FK reference to the user that created those listings (user id)?
    j
    • 2
    • 2
  • Validate JWT
    n

    nako

    11/06/2022, 2:58 AM
    Hello, after all, how to validate JWT on my own backend? Is there any supabase function?
    g
    n
    b
    • 4
    • 9
  • Avatar image changes not reflecting on UI
    x

    xHect

    11/06/2022, 3:45 AM
    Hello I was reading some other threads related to this and I know a fix would be to just have '${name}_${Date.now()}' but this will create a new entry in storage. I am not anticipating a TON of people changing pfp's , but is there a way to change the cache to be revalidated in a smaller time frame than it is currently in order to avoid creating a new object in storage each time keeping it as '${name}' . Apologize in advance if my wording is confusing
    j
    • 2
    • 2
  • Force subscription to be open all the time
    m

    MATTI

    11/06/2022, 10:02 AM
    I have an electron app where I use a subscription on a page. Sometimes when I go to the page the subscription is "open" and works fine. But other times it is "closed", and doesn't work. Is there a way to force it to open every time, so it always works?
    j
    • 2
    • 2
  • Vercel - Python
    s

    StephenBawks

    11/06/2022, 12:18 PM
    Running into a problem when including
    supabase
    in my Vercel serverless function. Seems to be failing during the build phase and pukes out an error.
    n
    • 2
    • 4
  • Getting error Column 'start_vid' not Found when using pgr_tsp extension from pg_routing
    a

    Aqshol Afid

    11/06/2022, 12:20 PM
    Hi everyone, i've try to using extension pg_routing and using pgr_tsp function, i've already follow documentation from pg_routing. but when i try in supabase somehow gotten error. here how i using the query
  • What can I do to improve my text search functionality?
    l

    lewisd

    11/06/2022, 2:28 PM
    Hi guys, I've got a generated column on my
    pokemon
    table called
    document
    . This column is basically a
    ts_query
    I currently have a function which works ok like so:
    Copy code
    ...
    LANGUAGE plpgsql
    AS $$
    begin
            return query
        select p.* FROM "pokemonView" p
        where p.document @@ to_tsquery('english', search_query);
    end
    $$;
    In this example, I'll use a Pokemon name as an example of what my app is currently doing. 1. Searching
    Bulbasaur
    returns the correct rows. 2. Searching
    Bulbasau
    returns no results. 3. Searching
    Bulbasaer
    returns no results. So basically I would like to have partial text search and fuzzy text search. Does anyone know how I could amend the above function to help with this? I have the
    PG_TRGM
    extension enabled but also have the
    FUZZYSTRMATCH
    extension enabled, however i don't think im utilising the latter.
    • 1
    • 2
  • REST API unreliable when called from a Vercel edge function
    h

    httpteapot

    11/06/2022, 3:38 PM
    Hello, I use the REST api of supabase to insert a record into a table
    fetch(mySupabaseEndpoint, {method: "POST", headers, body})
    . It works when I run this function locally, but not when I deploy it to a Vercel edge function. What is weird is that : - It's unpredictable, it works 1/4 of the time - there is no error or exception - I don't get result from the
    fetch
    , it hangs indefinitely. If I
    await fetch(...); console.log('hello')
    , the text
    hello
    is not displayed I'm calling other API from this same Vercel edge function with no issue. Any idea what could be the problem here?
  • Set complex return type = SQL function
    t

    talpiven

    11/06/2022, 5:47 PM
    Cannot figure out how to define the return type , I dont understand how to debug + get the right types, if I copy paste the types from it still does not work. Failed to run sql query: return type mismatch in function declared to return record
    Copy code
    select COLUMN_NAME, data_type
     from  INFORMATION_SCHEMA.COLUMNS
    where TABLE_NAME = 'cards'
    Copy code
    CREATE OR REPLACE FUNCTION public.get_cards()
        RETURNS TABLE(id bigint, updated_at timestamp with time zone, user_id uuid, name character varying, images_urls character varying[], description character varying, is_tradeable boolean, type smallint, favorites integer, views bigint)
        LANGUAGE sql
    AS $function$
    select car.* , count(fav.collectible_id) as favorites, view.count as views
     from cards car
     join favorites fav on car.id=fav.collectible_id join views view on fav.collectible_id=view.collectible_id
     where fav.collectible_type=1 and view.collectible_type=1
     group by car.id , fav.collectible_id, view.count
    LIMIT 20 OFFSET 0;
    $function$
  • How to generate JWT_SECRET?
    k

    kingweb

    11/06/2022, 6:06 PM
    Use your JWT_SECRET to generate a anon and service API keys using the JWT generator. (Mentioned in https://supabase.com/docs/guides/hosting/docker) Where can I generate this JWT secret?
    g
    • 2
    • 13
  • How to Store and Retrieve Session Data after Signing In?
    a

    Askar

    11/06/2022, 6:49 PM
    I try to log in with Twitter, and it redirects me and works as suspected. However, I'm unsure on how to retrieve the details after signing in. But, the session is immediately gone after redirecting and not sure how to get more details.
    Copy code
    const { data: user, error } = await supabase.auth.admin.listUsers()
    this always returns an empty list so not sure how to get the data after signing in How does one have a twitter authentication just for verifying the twitter login they have without making it the main login on the site? I already have an __authentication method using Rainbowkit to sign in with Wallet__, but i just want to authenticate Twitter handle for user profile
    Copy code
    js
    import supabaseClient from "../utils/supabaseClient.js"
    
    export default function Home(props) {
    
      const [name, setName] = useState("Verify Twitter")
      const [session, setSession] = useState(null);
      const supabase = supabaseClient()
      async function signInWithTwitter() {
        console.log(supabase)
        const { data, error } = await supabase.auth.signInWithOAuth({
          provider: 'twitter',
        })
        console.log("data", data)
        const { data: { sessionData } } = await supabase.auth.getSession();
        console.log(sessionData)
      }
      ...
    in picture: not sure how to get existing data after logging in as it redirects and that data is lost
    g
    z
    • 3
    • 36
  • what is default value of $PGPASSWORD and how to set a value ?
    k

    kingweb

    11/06/2022, 7:05 PM
    i saw $PGPASSWORD in https://github.com/supabase/supabase/blob/master/docker/volumes/db/roles.sql but i could not find value of this variable in https://github.com/supabase/supabase/blob/master/docker/.env.example what is difference between $PGPASSWORD and POSTGRES_PASSWORD? what is value of PGPASSWORD do i have to add and set value of PGPASSWORD in .env file?
    c
    • 2
    • 2
  • Typescript return type for Functions
    c

    Cody

    11/06/2022, 8:15 PM
    I really appreciate the
    supabase gen types typescript
    utility in the CLI tool. One thing I can't get to work is when I define Postgres Functions, it won't determine the return type based on the the function. For example, given this function
    Copy code
    sql
    create or replace function shifts_by_week(date timestamp default null)
    returns setof shifts
    as $$
      select * from shifts where date_trunc('week', coalesce($1, current_date) + interval '1 day') - interval '1 day' = date_trunc('week', shifts.date + interval '1 day') - interval '1 day';
    $$ language sql;
    Where I'm specifying the return is
    setof shifts
    which is a table in my schema. The generated type for this is
    Copy code
    typescript
        Functions: {
          shifts_by_week: {
            Args: { date: string }
            Returns: unknown
          }
        }
    I can manually update the file, sure, but it is auto-generated, so I'd rather not. And yes, I could also build a bash script that will generate the types and then mutate them at the end, but I'd rather not.
    • 1
    • 1
  • How can I authenticate a user with a local supabase during development?
    k

    kha

    11/06/2022, 8:48 PM
    I have setup a local supabase for local development. I am using magic link for authentication, and I don't see the activation email. Is there a way for me to retrieve the authentication URL in some way to bypass this?
    g
    • 2
    • 3
  • Possible to alter user data prior to User select?
    p

    PatD

    11/06/2022, 9:33 PM
    Hi, I was wondering, is there a way to add to the user data being returned with the
    useUser
    to pass it custom data from another table?
    j
    g
    +2
    • 5
    • 30
  • Where is the directory for platform api?
    d

    Deleted User

    11/06/2022, 10:07 PM
    I'm investigating an open issue on the public repo. The issues is pointing me towards the
    api.supabase.io/platforms/...
    . However, the local Nextjs API route doesn't seem to match this endpoint. Where can I find the directory to inspect the platforms endpoint?
    g
    • 2
    • 6
  • What's the difference between statement and row for triggers?
    g

    gtims123

    11/06/2022, 11:56 PM
    When creating a trigger, the user has the option to set the trigger to fire once for each processed row or once for each statement. I'm struggling to understand what the difference is exactly. Can anybody please help elaborate? What statement is it referring to?
    g
    z
    • 3
    • 5
  • pass jsonb to rpc
    u

    ((()))

    11/07/2022, 1:24 AM
    as seen in screenshot value needs to be jsonb, but I am not sure how to pass it jsonb
    Copy code
    js
    let claim = 'claims_admin', claim_value = toString(admin);
    const { error: claimErr } = await supabaseClient.rpc('set_claim', { user_id, claim_value, claim });
    I am trying as code above but getting error
    Copy code
    text
    Could not find the public.set_claim(claim, claim_value, user_id) function or the public.set_claim function with a single unnamed json or jsonb parameter in the schema cache
    s
    • 2
    • 3
  • Help with understanding why the query in JS SDK works like it works.
    u

    urth

    11/07/2022, 2:08 AM
    Hi, EDIT: I'll make the code look as code to improve readability, didn't know there was an option I had an issue where my API Endpoint, which was tasked with setting online status like this:
    await locals.supabase.rpc('set_online', {user_id: user.id, online: true});
    Was delaying the API response for a simple SET call ( I was not reading anything, nor was there a reason to wait for this call to finish ). I checked the Networks tab, saw that the API response is 200ms. Alright, what if I do this without awaiting for the call:
    locals.supabase.rpc('set_online', {user_id: user.id, online: true});
    Instant improvement, 60ms call. However, no change was made inside the database. What's the fix? It is:
    locals.supabase.rpc('set_online', {user_id: user.id, online: true}).then(f => f)
    Response is sent back in 60ms and the value is updated, which made me wonder why I had to call then(f => f) when I do nothing with the resolved promise. As I understand it, the type which is returned from:
    locals.supabase.rpc('set_online', {user_id: user.id, online: true})
    Is a query builder,. To my understanding, a query builder type has to be built in an async way, and after it's done with setting up the paramaters, we actually make the call ( why I have to use await or useless then ). Questions: 1. Is my understanding of the supabase ways correct? 2. If it is, why is there a need for the query builder type to be build in an async fashion? If possible, could you point me to the code which is responsible for the query builder type to be built async? 3. Is this mentioned in the docs anywhere? Thanks!
    z
    g
    • 3
    • 4
  • canceling statement due to statement timeout
    j

    jar

    11/07/2022, 2:19 AM
    according to https://supabase.com/docs/guides/database/timeouts set statement_timeout to 60000; -- 1 minute in milliseconds would change this i tried set statement_timeout to 300000; -- 5 minute in milliseconds Is there a limit to this or something. It doesnt seem to be working. I have a lot of math in func. Works in small inc but want to loop through many but times out with larger group. Do I need to try one of those upgrades with more cores or whatever (idk what that really means)
  • PostgreSQL 15
    j

    Jingly

    11/07/2022, 2:34 AM
    A little late to the game, but I just saw the PostgreSQL 15 was released a few weeks ago. I see a question was already posted about when supabase would start using the new version, but no answer... I was wondering if there had been any update when, or if, supabase plans to convert over to 15?
    s
    • 2
    • 2
1...616263...230Latest