https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Create user trigger 500
    a

    anderjaska

    09/14/2022, 4:46 PM
    I have this trigger:
    Copy code
    create or replace function public.handle_new_user()
    returns trigger as
    $$
      begin
        insert into public."User" (id, email, userType)
        values (new.id, new.email, new.raw_user_meta_data->>'user_type');
        return new;
      end;
    $$
    language plpgsql security definer;
    
    drop trigger if exists on_auth_user_created on auth.users; 
    create trigger on_auth_user_created
      after insert on auth.users
      for each row
        execute procedure public.handle_new_user();
    But I get a 500 on user signup. I can see the user_type field in the auth panel. My only guess is that
    userType
    in the
    User
    table is an enum, but I don't know how to cast it properly
    g
    • 2
    • 10
  • Twitter Auth does not work even after upgrading to Elevated Status
    e

    Ethanxyz

    09/14/2022, 5:23 PM
    I am trying to use Twitter Authentication with supabase, but am running into the classic
    http://localhost:3000/?error=server_error&error_description=Error+getting+user+email+from+external+provider
    error. All fixes to this issue say that I should obtain elevated status, but the same error is happening even after obtaining elevated status from Twitter. I am able to send the user to the Twitter Flow, but upon redirect I get the
    Error+getting+user+email+from+external+provider
    error. Any help would be appreciated. Edit: Here is some more information. Seems like it works for others. https://github.com/supabase/supabase/discussions/5915
    • 1
    • 8
  • Is it possible to import specific modules of the supabase client?
    a

    anderjaska

    09/14/2022, 7:40 PM
    Such as Auth and Storage. The motivation is to reduce bundle size
    g
    • 2
    • 1
  • Time Triggered Edge Functions
    s

    Sonny Vesali

    09/14/2022, 8:19 PM
    Hi all I have a spec where I want a function that updates a value in my supabase real time database periodically or on demand. So if a user does a particular thing it updates, but if nothing happens it then falls back to the action done at the periodic interval. Is this possible? I haven't found anything on the internet related to this, it seems that it will require another edge function, but that's as far as I've gotten, thanks.
    g
    • 2
    • 3
  • Updating SB, need help pointing the previous db yaml
    r

    rgfx

    09/14/2022, 10:04 PM
    Some wonderful person posted this in the github community. > The docker-compose.yaml for the db container has the default volume path of - ./volumes/db/init:/docker-entrypoint-initdb.d. This creates the database when starting up the container but if noone changes that, it means, this will always be repeated on every start. The compose file has the comment value # - ./volumes/db/data:/var/lib/postgresql/data. So I copied the previously created container from /var/lib/docker/ to that path, removed the init volume path, uncomment the other and after the next docker compose up -d the database was there again. 🙂 I don't this part
    So I copied the previously created container from /var/lib/docker/
    I unable to find the location of the database files to move them into my created folders
    ./volumes/db/data:/var/lib/postgresql/data
    where is my database located? I don't want to lose my data each time I update.
    s
    • 2
    • 3
  • Attach debugger to edge functions
    w

    wesleyyue

    09/14/2022, 10:25 PM
    Hi, is there a way to attach a debugger to locally served edge functions like you can in Deno? https://stackoverflow.com/questions/61853754/how-to-debug-deno-in-vscode https://deno.land/manual@v1.25.2/getting_started/debugging_your_code
  • Creating edge function for redirect url to deep link
    t

    Tony_n

    09/14/2022, 11:21 PM
    I have deep linking working in my react native application currently, however I am having issues with third party apps requiring a return url that starts with http. For supabase I was able to just give them my deep link url of betabridge:// and it worked. I tried to create an edge function that redirects to betabridge:// but it only accepts post requests so it will not work. I would rather not spin up a site or server just for this as I am tring to go to market as quickly as possible. Is there any way to achieve this?
    f
    • 2
    • 12
  • manually use setAuth() on SIGNED_IN?
    e

    enti

    09/14/2022, 11:40 PM
    Do we have to use
    setAuth()
    on our current SupabaseClient Object once we receive the
    SIGNED_IN
    Event with its
    session.access_token
    , or does the SupabaseClient Object updates itself through the
    signIn()
    process? Asking to be sure because it looks like my API calls still seem to use the anon access token post signIn()
    s
    g
    • 3
    • 6
  • Supabase hosted db getting max_client_conn error
    h

    hongymagic

    09/15/2022, 3:42 AM
    App hosted on Vercel, using Next.js and Prisma - configured to use the connection pooling URL currently hitting this - connection limit hasn't been reached from what I see Can anyone help with this please? Full error message:
    Copy code
    Error querying the database: db error: FATAL: no more connections allowed (max_client_conn)
    y
    • 2
    • 5
  • Minimal Requirements for self-hosting
    m

    marcus_polonus

    09/15/2022, 5:13 AM
    What are minimum recommended VPS requirements for self-hosting? I wonder what is the starting point in terms of CPU and Ram
  • Conditional Trigger
    a

    AlanK

    09/15/2022, 6:25 AM
    I'm hoping to create a trigger that fires when the email_confirmed_at field is updated in the auth.users table BUT only if the invited_at field is NOT NULL. If this is possible I'd appreciate some hints.
    t
    • 2
    • 3
  • How can I upgrade Postgres?
    m

    Monkeybanana

    09/15/2022, 7:36 AM
    Has Supabase said how Postgres updates happen? My current instance is on 14.1, but I believe that 14.5 is the latest.
    g
    • 2
    • 3
  • Password reset for phone authentication
    n

    neoc

    09/15/2022, 7:37 AM
    Hey yall, are there some docs about reseting passwords for users who used only phone auth? I'm seeing this rn but doesn't seem to work for phone auth: https://supabase.com/docs/reference/javascript/auth-api-resetpasswordforemail thanks 🙂
  • Can't login using js-v2 rc.10
    d

    doctor_eval

    09/15/2022, 7:49 AM
    So I upgraded to the RC version of JS - and now I can't log in from my code. I'm playing around on my laptop at the moment so I just want to be able to log in using a hard coded email and password, and then use that session to make RPC calls to Supabase. But my code isn't working. I wrote a database function to return the current user and role, and it's returning null and "anon". Here's my login code. I'm sure it's something really stupid.
    Copy code
    import {createClient} from "@supabase/supabase-js";
    
    let client = createClient(
        'http://supabase.example.com/',
        'supabase-anon-api-key',
    );
    
    const { data, error } = await client.auth.signInWithPassword({
        email: 'user@example.com',
        password: 'random-password',
    })
    
    if (error != null) {
        throw error
    }
    
    let userinfo = await client
        .rpc('userinfo', {})
    
    console.log("Got userinfo", userinfo)
    
    // prints: {
    //   error: undefined,
    //   data: { uid: null, role: 'anon' },     <-- this should be role "authenticated"
    //   count: undefined,
    //   status: 200,
    //   statusText: 'OK'
    // }
    g
    • 2
    • 20
  • Transformations availability
    w

    Waldemar

    09/15/2022, 8:15 AM
    I'm currently evaluating Supabase Storage vs. Cloudflare Images for hosting around 10,000 photos for our website. The main argument for CF Images is that they have transformations (variants). On the negative, I would need to have my domain in CF to be able to set Cache-Control. And in general I'd like to stick to Supabase where possible. Is there even a super rough estimate when Storage Transformations will be available? 1 month? 2 months? 4 months? More? Will it be possible to set up pre-defined variants (as opposed to providing the parms in the URL each time, like ?w=800&h=600)?
  • Using meta api in the cloud
    a

    avif

    09/15/2022, 8:29 AM
    I want to use the meta api in the version, build tables and columns. Is it possible? if so how? Is there a NOSEJS client for that? Thanks
    k
    • 2
    • 1
  • Is it safe to send login details through supabase client when hosted locally with localhost?
    a

    antimatroid

    09/15/2022, 1:32 PM
    I'm semi confident this is okay because when creating the client it uses the project url which is https along with the public api key for the project, but wanted to double check as I'm not 100% knowledgeable on these things under the hood.. I typically enforce https when hosted, but out of curiosity same question for websites accessible through http?
    s
    • 2
    • 3
  • policy not working
    e

    enti

    09/15/2022, 2:10 PM
    I got a table named
    companies
    with RLS enabled. I created a policy to allow SELECT for any authenticated user + anon. I do my API call from my Vuejs client with an authenticated user :
    Copy code
    js
    const { data, error } = await supabase
            .from("companies")
            .select(
              "id, nom, raison, adresse, cp, ville, pays, id_name, uuid, resipay"
            );
    I check my API call live on the XHR console and the authenticated token is in the header. Yet I get a 403 response from supabase... What did I miss?
    e
    g
    • 3
    • 16
  • How do you save the `access_token` cookie on the client to be accessed with SSR or Middleware?
    a

    andyjakubowski

    09/15/2022, 3:22 PM
    I’d like to check for the
    access_token
    cookie server-side, for example in Next.js
    getServerSideProps
    via the
    context.req.cookies
    argument. Depending on the existence and validity of the
    access_token
    , I’d like to serve either protected content or redirect the user. But
    gotrue-js
    doesn’t seem to save the cookie on the client automatically. Is there a recommended way to do this? I noticed that @alaister proposed a new setup for [
    supabase/auth-helpers
    ](https://github.com/supabase/auth-helpers/pull/239) where
    withPageAuth
    has the Supabase client read the request/response headers for a cookie and uses that to set a session server side. But for that cookie to be sent by the browser to my app, say app.vercel.com, I need to first have something save the cookie. The responses from the Supabase Auth API do come with a
    Set-Cookie
    header that holds the
    access_token
    , but the
    Domain
    attribute is set to the Supabase project URL (
    <xyz>.supabase.co
    ) — which means this cookie is not passed to my app’s server. I see two options to address this: 1) Save the cookie on the client in an
    onAuthStateChange
    callback, which will set the cookie’s domain to be the same as the app server.
    gotrue-js
    doesn’t seem to set any cookies on the client, so we’d do that ourselves. 2) Route the login traffic through an API route so that the
    Set-Cookie
    header with an access token comes from my app’s domain. Am I missing something obvious here? How do you ensure that the
    access_token
    gets passed in the cookie when calling your app server and can be used to set up a session in
    getServerSideProps
    in Next.js, API routes, or in middleware?
    j
    v
    • 3
    • 16
  • EU GDPR Compliance - Host in EU?
    k

    KickSquare

    09/15/2022, 3:36 PM
    As far as I know, you are legally required to host your database in the EU if you have users from the EU: "The GDPR requires that all data collected on citizens must be either stored in the EU" (https://www.archive360.com/blog/data-sovereignty-and-the-gdpr-do-you-know-where-your-data-is) Is there an option to have your supabase database hosted on EU servers to stay compliant?
    s
    • 2
    • 5
  • [Non-urgent] Is there a good Postgresql doc on different types of returns for RPCs?
    i

    InASunshineState

    09/15/2022, 4:13 PM
    Sometimes I just want a table-like result, as if I was trying to produce a view, except I want to feed it parameters. I know there's RETURN TABLE AS, RETURN TEXT AS, RETURN SETOF, etc. but knowing the full list of choices as well as how and when to use them -- I'm sort of lost. Supabase docs have limited direct query coverage for obvious reasons, but since it's a capability and it's all a wrapper, I am trying to learn more about Postgresql in general to inform my choices here. I just genuinely can't find anything in a search that explains it in a way that "registers."
  • undefined is not an object (evaluating 'globalThis.localStorage.getItem')] in react-native
    u

    0verread

    09/15/2022, 4:15 PM
    Getting this error. I'm assuming this is something to do with localStorage. relavant stackoverflow issue https://stackoverflow.com/questions/68763589/undefined-is-not-an-objectevaluating-this-localstorage-getitem-error-in-reac can someone help me with this? I tried to clean localStorage too. didn't work.
    g
    • 2
    • 19
  • How to use NOTIFY without triggers or functions?
    p

    ProtoFeather

    09/15/2022, 4:28 PM
    Hi! As you may know, triggers and functions are not production ready within Supabase. How would one go about getting notifications (for use in python) with the operation as a payload? What I did was
    cur.execute(f"INSERT INTO mydb (model, img, multi_dl) VALUES ('{model}', '{img}', '{multi_dl}'); NOTIFY test, 'placeholder';")
    I'd like the placeholder to be the operation I just executed (intert into...). Any ideas?
    t
    g
    • 3
    • 11
  • prepared statement s0 already exists
    w

    Wonie

    09/15/2022, 4:41 PM
    When I try to use Supabase DB with Prisma, I get this error
    • 1
    • 1
  • Supabase auth next.js
    a

    Aron

    09/15/2022, 6:06 PM
    When I try to follow this doc, https://supabase.com/docs/reference/auth-helpers/next-js, I just get authListener.unsubscribe is not a function...
  • Supabase general access
    s

    steezli

    09/15/2022, 6:25 PM
    We are starting a new project at work and are having consistent issues getting access to app.supabase.com. Primarily because github is the only way to authenticate. My personal email wa my primary github email but I was invited to supabase with my work email. Is there a way to completely detach github from supabase and regenerate my account?
  • Should I store an order total as an int or total up every items price when querying the db?
    l

    lewisd

    09/15/2022, 7:22 PM
    More of a general SQL question than supabase. Im creating a marketplace and designing the schema that will hold my users
    orders
    . An order can have many
    lineItems
    . As I'm coming from firebase, I would just usually have an
    order
    document. It would have an
    orderTotal
    field. The
    lineItems
    would also be part of this
    order
    document. However, now that my db is relational and split into tables, is it best practice to store totals like I have done before or should I calculate the total price when selecting all my
    lineItems
    ?
    s
    • 2
    • 2
  • Solved - Invoke edge function returning buffer-blob
    n

    najjannaj

    09/15/2022, 7:46 PM
    Hi there, I want to invoke an edge function that returns a buffer/blob of a created File. If I call the function via REST and save the output directly to a file it works great. But If I call the function with "supabase-js@2.0.0-rc.10" and trying to save the data-result the file is always corrupted. Any ideas what to do? Example snippet:
    Copy code
    supabase.functions.invoke<Blob>('createInvoice', {
          body: { invoiceId: invoiceId }
    }).then(res => FileSaver.save(res.data))
    Best regards, Jan
    • 1
    • 1
  • how to pg_restore a supabase db
    p

    pocin

    09/15/2022, 8:16 PM
    I am about to deploy a large number of migrations. Before doing that i would like to test them one more time against prod database but on localhost. I have
    pg_dumpall
    my prod instance. Running
    Copy code
    supabase start
    pg_restore -cC -d postgres -e ./postgres.custom
    gives
    Copy code
    pg_restore: from TOC entry 3540; 1262 12974 DATABASE postgres postgres
    pg_restore: error: could not execute query: ERROR:  cannot drop the currently open database
    When i
    psql
    and
    Copy code
    create database temp;
    \c temp;
    drop database postgres with (force);
    I get
    Copy code
    ERROR:  database "postgres" is used by an active logical replication slot
    DETAIL:  There is 1 active slot.
    but
    pg_subscription
    is empty. How can i restore a database from a backup?
    • 1
    • 7
  • Best way to add social accounts to a person
    l

    louisstephensca

    09/15/2022, 8:44 PM
    I am working on a small app right now with NextJS that basically has 2 parts. There is a public/client facing landing page where information from the database will be displayed. The page will contain a basic message, contact information, and links to their social accounts. The other part is an admin only page (registered supabase users) with a form for creating new clients. I set up a table named "clients" that has all of the necessary columns (name, message, street, city) except for their social media links. I am a bit stuck on how to proceed with this at the moment. My first thought was to just have preset social columns in the table and have the form write directly to those. However, I am thinking I might run into some issue down the line where the I have not accounted for a type of account. Should I just use an array on varchar with objects, or is there a better way to go about this? I do apologize if this confusing. If any more clarification is needed please let me know!
    e
    • 2
    • 5
1...232425...230Latest