https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Realtime Concurrent Peak Connections
    b

    BoogersLLC

    05/01/2023, 12:22 PM
    Hello, I currently am exceeding the Realtime Concurrent Peak Connections. Although, I don't know how this is possible. I'm assuming I have a bug where I must be creating and not closing connections? I only have about 250 users, few of which actively use the app, hence why I'm skeptical of this number. Is there a way to debug this, or a way to prevent multiple connections from a single browser? I'm not sure exactly where to start looking
    g
    k
    r
    • 4
    • 9
  • Edge functions failing to fetch data from API
    r

    Rytterboi

    05/01/2023, 12:43 PM
    I need to fetch data from an API to use in my database. I have tried more less anything under sun to get it to run however the closest to a success i have managed to get is the code below. It runs and logs a piece of the response but fails half the time anyways because it often does not log the part of the response that contains the esrejendomsnr im trying to extract from the response. Handling the reponse any other way fails entirely. What might i do here or is there simply no way to handle this with edge functions? In that case what are my alternatives? The error the function throws is Error reading stream: TypeError: error decoding response body: unexpected end of file at eventLoopTick (ext:core/01_core.js:165:11) at async Object.pull (ext:deno_web/06_streams.js:744:27) Thanks in advance šŸ™‚ import { serve } from "https://deno.land/std@0.168.0/http/server.ts"; console.log("Hello from Functions!"); serve(async (req) => { // Define CORS headers const corsHeaders = { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, OPTIONS", "Access-Control-Allow-Headers": "Content-Type", }; // Handle OPTIONS request for CORS preflight if (req.method === "OPTIONS") { return new Response(null, { headers: corsHeaders }); } if (req.method === "GET") { try { const url = new URL("https://api.dataforsyningen.dk/adresser"); url.searchParams.append("q", "Ottosgade 2A 6000 Kolding"); const response = await fetch(url, { keepAlive: true }); if (response.ok) { console.log("Response status:", response.status); console.log("Response headers:", response.headers); // Read the entire response using an async generator const rawResponse = await readEntireStream(response.body); console.log("Raw text response:", rawResponse); // Extract "esrejendomsnr" value using a regular expression const esrejendomsnrMatch = rawResponse.match(/"esrejendomsnr":\s*"([^"]+)"/); if (esrejendomsnrMatch) { console.log("esrejendomsnr:", esrejendomsnrMatch[1]); } else { console.log("esrejendomsnr not found"); } } else { console.error("Error fetching data:", response.statusText); } } catch (error) { console.error(
    Error in fetching data:
    , error); } return new Response("Data fetched and logged", { headers: corsHeaders }); } return new Response("Not Found", { status: 404 }); }); // Helper function to read the entire stream async function readEntireStream(stream) { const reader = stream.getReader(); let result = ""; const decoder = new TextDecoder(); try { while (true) { const { done, value } = await reader.read(); if (done) { break; } result += decoder.decode(value); } } catch (error) { console.error("Error reading stream:", error); } finally { reader.releaseLock(); } return result; }
  • Selfhosted supabase, when trying to add a new user error with "dns resolution failed"
    t

    tr1cksnl

    05/01/2023, 1:32 PM
    I'm guessing it has to do with mailserver (whatever sends mail in the background) not being able to properly use the dns resolver.
    • 1
    • 1
  • search text array column with ilike in supabase-js
    m

    mattposgate

    05/01/2023, 2:10 PM
    Hi, I'm playing around with array columns and just wondering if it's possible to search a column that's got arrays of email addresses in with a like or ilike. Column is text[]. eg qry.ilike("email_addresses","%googl%")
    r
    g
    • 3
    • 4
  • Next 13 Supabase Auth Helpers (app dir) - Setting headers + cookies in RSC available??
    m

    MusashiGarami

    05/01/2023, 2:12 PM
    Following : https://supabase.com/docs/guides/auth/auth-helpers/nextjs-server-components It states: "Next.js only provides read access to headers and cookies in Server Components and Route Handlers, however, Supabase needs to be able to set cookies and headers to refresh expired access tokens." But looking at: https://beta.nextjs.org/docs/api-reference/response I'm seeing the ability to read or mutate set-cookie header. response.cookies.set() Am I looking at the wrong stuff here? It looks like NextRequest and NextResponse is able to set cookies... Is this simply new functionaility since the supabase docs was written ( i know the experiemental beta nature of all this) or am I just looking at the wrong things here? (quite possibly)
    • 1
    • 1
  • Cannot create a new member
    s

    systemaddict

    05/01/2023, 2:29 PM
    Hi. I simply cannot invite a new member. I've tried both invite and create new member, but neither works. The member is visible on the list, but the email/password doesn't work. Also tried "forgot password" but it is not sent. Also, not sure if related, the activation link redirects to localhost even if we are on the cloud version.
    r
    g
    • 3
    • 5
  • Acquiring 6 digit OTP code while running local dev instance of supabase
    r

    RONEN

    05/01/2023, 3:02 PM
    Hi, I got stuck not being able to find a way to retrieve the 6 digit OTP code. Since local version of supabase doesn't have all the features I am unable to modify the email templates where I would change it to send .Token. How can I retrieve the token when a new user signs up? Thank you.
    s
    g
    • 3
    • 5
  • Jsonb subfield is fetched a string instead of an array
    b

    BassemAzizi

    05/01/2023, 3:45 PM
    Fetched jsonb with graphql from supabase return a subfield array as a string Help please
  • invisible unicode characters
    n

    nimo

    05/01/2023, 4:56 PM
    i'm seeing an error that says "this document contains many invisible unicode characters" I'm not sure where they're coming from, or how to query them. Does anyone have any advice on how to figure it out? I googled around, it suggested using
    encode(COLUMN, 'escape')
    but this function doesn't appear to exist in supabase.

    https://cdn.discordapp.com/attachments/1102639808163102730/1102639808284741782/Screenshot_2023-05-01_at_12.55.49_PM.pngā–¾

    • 1
    • 1
  • download denied for files within a directory of a public bucket
    b

    brt

    05/01/2023, 5:01 PM
    Hi, I've set up a public bucket which should allow to download files. files from the root bucket download correctly (see the image attached), whereas if I try to download a file from an inner directory, it fails. I've removed any policy in order to make sure it should work properly. the only enabled policy is to list the public bucket. Keep in mind I"m using the supabase's interface to try it out. Not that sure if there's some missing policy to make it work, but I guess subfolders should work the same as the root, in case no further policies are set, right?
    g
    • 2
    • 9
  • iOS Auth: How do you ensure keep the user signed in, and keep the jwt valid?
    m

    Miles

    05/01/2023, 5:40 PM
    I'll type here as well but I made 2 issues on the community swift library: Auth tokens not refreshing properly: https://github.com/supabase-community/gotrue-swift/issues/53 User getting signed out: https://github.com/supabase-community/gotrue-swift/issues/52 I'm facing two issues when using the community swift library. I'm signing in via OTP with phone number which is working great, but then after the user signs in there are two issues: 1. Requests tend to 401 right around the time the auth token needs to be refreshed 2. The user sometimes gets signed out, without calling
    signOut
    or any changes happening in the user's account. For the requests hitting a 401, basically around the time the token expires and should refresh, calling
    try await client.auth.session
    and immediately sending a server request sometimes gives an error when then trying to use that token on the server (
    await getSupabaseAdmin().auth.getUser(accessToken)
    ). It is always expired within 60s, meaning I think this is a very simple case of refreshing the token too late in the logic of
    auth.session
    in the swift library. Does anyone have a fix for this? For the user sometimes getting signed out, sometimes I just get a random sign out event and sometimes the
    auth.session
    calls always throw an error:
    GoTrue.GoTrueError.APIError(message: nil, msg: nil, code: nil, error: Optional("invalid_grant"), errorDescription: Optional("Invalid Refresh Token: Refresh Token Not Found")
    . Does anyone know how to fix this? Thanks a lot in advance!
    t
    • 2
    • 12
  • Detecting a change
    d

    DignifiedSwine

    05/01/2023, 7:27 PM
    Just a weird one here. If I was to grab a list from a table 'tblOne', how would be the best way to check 4 inputs to see if they exist in the table without triggering a search 4 times. THEN if there is a change, figure out which one has been changed and update the table to match???
    g
    • 2
    • 18
  • Function works when called from the back end, but refuses to work when called from the front end.
    u

    š™²šš‘ššžššžšš”

    05/01/2023, 9:25 PM
    There is an issue that I've been struggling to fix. So, I have the following function...
    Copy code
    create or replace function entry_decit(jid_ int, choice text)
    returns void
    language sql
    as $$
      update journal 
      set status = case when (choice = 'y') then ('apr') when (choice = 'n') then ('rej') else ('und') end
      where journal.jid = jid_;
    $$;
    Running
    Copy code
    select entry_decit(49, 'y')
    , from the SQL editor runs the function as expected. But calling that same function from the front end produces the following errors...
    Copy code
    [Project URL]/rest/v1/rpc/entry_decit 400
    (anonymous) @ VM146 supabase-js@2:7
    (anonymous) @ VM146 supabase-js@2:7
    o @ VM146 supabase-js@2:7
    Promise.then (async)
    l @ VM146 supabase-js@2:7
    (anonymous) @ VM146 supabase-js@2:7
    o @ VM146 supabase-js@2:7
    (anonymous) @ VM146 supabase-js@2:7
    then @ VM146 supabase-js@2:7
    VM150 app.js:393  {code: '21000', details: null, hint: null, message: 'UPDATE requires a WHERE clause'}
    apr_jrnl_entry @ VM150 app.js:393
    await in apr_jrnl_entry (async)
    onclick @ VM155 jrnl_entry.html:1
    Copy code
    {code: '21000', details: null, hint: null, message: 'UPDATE requires a WHERE clause'}
    I'm sure it's not a RLS thing because another function that makes changes to another table works as expected when called from the frontend. It has the same RLS policies as this table. this is the call BTW...
    Copy code
    async function apr_jrnl_entry(ch) {
        //does not want to work for sum reason
        let jrnl_id = (new URL(document.location)).searchParams.get('journal')
        console.log(ch + jrnl_id);
        let { data, error } = await sb.rpc('entry_decit', {jid_: jrnl_id, choice: ch})
        if (error) {
            console.error(error)
        } else {
            console.log(data)
        }
    }
    Thanks in advance.
    g
    • 2
    • 10
  • Sveltekit Endpoints
    h

    Hugos

    05/01/2023, 10:30 PM
    I have sveltekit endpoint setup and once that endpoint is reached I need to get the supabase client to make some calls to the database, but when I try to do that I notice that my RLS blocks me from interacting with the database, so how do I use the supabase client inside sveltekit endpoints? I cannot use the service_role here because I still need to make sure only people with admin claims can hit that endpoint successfully
    j
    • 2
    • 5
  • how to test a RLS with pgTAP for a specific role/user
    b

    brt

    05/02/2023, 12:27 AM
    Hi! I have a table with some RLS. For instance, it can be queried (select) from any public role, but not updated nor inserted/deleted etc. I would like to test this by executing some pgtap test with the proper role, but I'm not that sure I can do it because I'm not finding any example online. Could you suggest me some example to take inspiration from? thanks
    g
    s
    • 3
    • 12
  • How to check current size of specific table?
    h

    Hartaithan

    05/02/2023, 1:00 AM
    Something like this: select sum(pg_database_size(pg_database.datname)) / (1024 * 1024) as db_size_mb from pg_database; But for specific table
    g
    • 2
    • 2
  • my db was super slow. I fixed it by upgrade to bigger machine. how to monitor regularly?
    n

    noOne

    05/02/2023, 1:06 AM
    All signs in the dashboard looks normal
  • vercel auth template hydration issue
    f

    fortuitoustortoise

    05/02/2023, 1:47 AM
    Hello, I'm trying to set up a project using the Supabase template here: https://vercel.com/templates/next.js/supabase-authentication But rendering the index page gives me the attached hydration error... It seems like there is a component in the Supabase library that is leading to a lingering tag. I don't have time to look through all of the Supabase UI components to see which one it might be. Any tips would be greatly appreciated!

    https://cdn.discordapp.com/attachments/1102773380073132193/1102773380261888050/Screen_Shot_2023-05-01_at_20.45.03.pngā–¾

  • Custom data management same primary key as auth.users?
    v

    Vireve

    05/02/2023, 2:22 AM
    I want to have custom user data and in the docs (https://supabase.com/docs/guides/auth/managing-user-data) they reference creating your own table like
    public.profiles
    that is essentially 1 to 1 with
    auth.users
    . Should I just make the primary key of
    public.profiles
    the same as
    auth.users
    ? As a follow up, for all tables that depend on a user, should I make sure to reference
    auth.user.user_id
    g
    • 2
    • 4
  • Is supa_audit available as an extension in Supabase?
    d

    Dawnmist

    05/02/2023, 3:16 AM
    I was reading the blog post by Supabase at https://supabase.com/blog/audit about creating a table for keeping an audit trail for database modifications, and at the end it linked to the supa_audit extension. I wanted to ask if this was available within Supabase as an extension that could be enabled? I couldn't find it under that name in my current account, but there was an extension called supautils so I was wondering if it was maybe included inside that one? If it's not there, would the best option be to copy the current full-sql file from the supa_audit repo (https://github.com/supabase/supa_audit/blob/main/supa_audit--0.3.1.sql ) into my own project as a migration file so that I can add it to my db? Or is there a better way to integrate it (so that I can get any future bug fixes flowing through automatically)?
  • Curious about maximum concurrent DB connection limit for each plan
    b

    BravoSix

    05/02/2023, 4:48 AM
    Hi Supabase community, I'm starting a new critical project for a client (with around 100K users) with Supabase postgres database as backend but I can't find any information about the maximum concurrent connection limit specific to database on each plan. Any help from the community will be appreciated. Bravo out.
    r
    g
    • 3
    • 8
  • Reset password link leads to an authenticated session?
    s

    shiftkeyisbroke

    05/02/2023, 6:18 AM
    I'm not sure what is going on or whether this is expected behavior or not. I am using the Auth UI and allowing users to reset their password. The email fires with the reset password link like expected and when the link is clicked, the user is redirected back to my application as expected. Is it expected that
    useUser
    from
    @supabase/auth-helpers-react
    returns back an authenticated session?
    l
    g
    • 3
    • 2
  • Preferred web dev platform
    j

    Jon

    05/02/2023, 6:29 AM
    Hi there, which is the preferred web dev platform that people using SB are leaning into? Ie I guess which one has the most comprehensive sdk for SB ? ( I’m looking at working on some admin type trolling for things like managing users and such)
    r
    • 2
    • 1
  • Local development custom email templates
    w

    Warlando

    05/02/2023, 7:56 AM
    I'm trying to create my own auth email templates in local development. I've seen the self-hosted docs where one could edit the env vars to something like this
    GOTRUE_MAILER_TEMPLATES_INVITE=<URL>
    but I'm not planning to self host and only want to be able to set my own email templates in local dev. How could I achieve this?
    s
    • 2
    • 3
  • how to use custom email for sign up
    r

    RB_Gaura

    05/02/2023, 8:06 AM
    basically supabase is sending verification emails from noreply@supabase, how can i send from my own email instead.
    g
    • 2
    • 1
  • Issue with policies. fixed.
    l

    LAH

    05/02/2023, 8:08 AM
    I wrote a POSTGRESS function like so:
    Copy code
    CREATE OR REPLACE FUNCTION check_role(uid_input uuid) RETURNS text
      LANGUAGE plpgsql
      AS $$
    BEGIN
      RETURN (
        SELECT role
        FROM auth.users
        WHERE id = uid_input
      );
    END;
    $$;
    but I have issues calling it in the policy:
    (check_role(auth.uid()) = 'admin'::text)
    my user has the role "admin" and when running the same code (as in the policy) in the "SQL editor" with the uid hardcoded it returns true. the role "admin" has permissions to see the table because if I only write "true" as the policy expression everything works as expected.
    g
    v
    • 3
    • 11
  • Is there an example of role based auth for Supabase
    b

    BakaPresident

    05/02/2023, 9:47 AM
    Hi there, I'm looking for an example of how to do a dashboard where admin can see what user has bought and control stuff while normal users are still restricted to RLS. Is there any hint or example projects to go about doing it in React?
    l
    g
    • 3
    • 4
  • We see a lot of 504 responses
    e

    erik-beus

    05/02/2023, 9:54 AM
    All of a sudden we see a lot of 504 responses from our supabase database. Is there a way to see more information about what's causing this? This query doesn't give us a lot of information
    Copy code
    select
      cast(timestamp as datetime) as timestamp,
      event_message,
      r.status_code
    from edge_logs
      cross join unnest(metadata) as m
      cross join unnest(m.response) as r
    where
      r.status_code >= 500
    order by
      timestamp desc
    limit 100
    r
    s
    • 3
    • 8
  • How to fetch inside svelte components?
    h

    Hugos

    05/02/2023, 9:58 AM
    I have a page load function that retrieves all orders from customers, but when I want to see details about that order I need to make a request to my order_products table but how can I do a fetch request on the client without the supabase client? The user stays on the same page so I can't run another load and loading in all data is unneccesary because 99% will not be accessed.
    • 1
    • 1
  • Creating a working trigger
    r

    RB_Gaura

    05/02/2023, 10:36 AM
    So I wanted to create a trigger function that would add a row into public.profiles when something was added to auth.users, but it seems I'm failing quite badly. This is the function itself:
    Copy code
    sql
    BEGIN
      -- Insert a row into public.profiles with metadata and profile data
      INSERT INTO public.profiles(id, created_at, updated_at, display_name)
      VALUES (NEW.id, NEW.created_at, NEW.created_at, NEW.raw_user_meta_data->>'name'
    );
    
      RETURN NEW;
    END;
    j
    g
    • 3
    • 10
1...198199200...230Latest