https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Custom local development database
    j

    Jimmy

    01/22/2023, 11:16 AM
    Hi team, is it possible to use custom database for local development? I have a large dataset of Australian addresses (GNAF), about ~20gb. It would be a great relieve if I could ship the custom database in a container (built on top of supabase database container) to my team members.
    • 1
    • 1
  • edge functions works when served, but deploy fails
    f

    fachofacho

    01/22/2023, 2:32 PM
    platform: Mac M1 arm64 supabase cli version: 1.33.0 command :
    supabase functions deploy total-hours-spent --debug
    output:
    Copy code
    Bundling total-hours-spent
    Error: Error bundling function: signal: trace/BPT trap
    file:///src/import_map.json
    file:///src/index.ts
    assertion failed [block != nullptr]: BasicBlock requested for unrecognized address
    (BuilderBase.h:550 block_for_offset)
    it seems that when i remove the imports, the code is bundled as expected. imports:
    Copy code
    import { createClient } from "https://deno.land/x/supabase@1.3.1/mod.ts"
    import { serve } from 'https://deno.land/std@0.131.0/http/server.ts'
    g
    a
    • 3
    • 6
  • Filter column that has following format.
    v

    VuNguyen

    01/22/2023, 3:29 PM
    I want to filter column that has value match the following format. Given by a number, example:
    5
    I want these type of value to match: 5 -> true anystringhere 5 -> true 55 -> false anystringhere 55 -> false 5 anystringhere -> false 55 anystringhere -> false Is there any way to achieve that without using rpc?
    g
    • 2
    • 113
  • How do you handle the CI/CD with supabase functions ?
    a

    Alaanor

    01/22/2023, 3:34 PM
    We got
    supabase db push
    for db migrations which is awesome but what about the edge functions ?
  • Facing issues with supabase db remote commit
    l

    lekt9

    01/22/2023, 3:53 PM
    After modifying the production instance via the UI, I am facing this error:
    Copy code
    Error: The remote database's migration history is not in sync with the contents of supabase/migrations. Resolve this by:
    - Updating the project from version control to get the latest supabase/migrations,
    - Pushing unapplied migrations with supabase db push,
    - Or failing that, manually editing supabase_migrations.schema_migrations table with supabase migration repair.
    Try rerunning the command with --debug to troubleshoot the error.
    s
    • 2
    • 3
  • How to change the url of redirect_to for e-mail templates.
    r

    rafael

    01/22/2023, 4:21 PM
    Hey guys there is any way to set the redirection url on email templates? right now, I'm using:
    Copy code
    {{ .SiteURL }}/confirm-signup?confirmation_url={{ .ConfirmationURL }}
    but the redirect_to is always poiting to my base url. There is any way to point to eg. {{ .SiteURL }}/completed/ ? Thanks
    g
    • 2
    • 9
  • Is this approach secure?
    f

    fast

    01/22/2023, 5:00 PM
    Hey there, I am kind of new to supabase so I was wondering if the following approach for identifying a user is secure using the access token => Client:
    Copy code
    const session = await supabase.auth.getSession();
    const accessToken = session.data.session.access_token;
    Server:
    Copy code
    // create supabase client
    const supabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE, {
      auth: {
        autoRefreshToken: false,
        persistSession: false
      }
    });
    Copy code
    // identify user
    async function getUserFromAccessToken(accessToken, res) {
        try {
          const supabase_response = await supabase.auth.getUser(accessToken);
          return supabase_response.data.user;
        } catch(e) {
          console.log(e)
          res.status(403);
          res.send({type: "error", message: "Forbidden!"});
          return false;
        }
    }
    j
    • 2
    • 6
  • Using Fresh with Supabase and signInWithOauth
    u

    UserUNP

    01/22/2023, 5:17 PM
    Fresh uses preact and preact can't have async components so i need to do this
    Copy code
    tsx
    export const handler: Handlers<User | null> = {
        GET: async (_, ctx) => {
            const data = await Supabase.loginUser();
            return ctx.render(data);
        }
    }
    where
    Supabase.loginUser()
    basically runs
    await Supabase.client.auth.getUser()
    and returns
    null
    if there's an error. Handlers in Fresh are ran on the server-side.. i don't really know how to make auth a user like that.
    • 1
    • 1
  • Xbox Authentication
    u

    UCDFiddes

    01/22/2023, 5:21 PM
    Is there currently anyway to allow users to login using Xbox on supabase. I've looked into logging into with Azure but I don't know how to get Xbox information.
  • how can i listen to changes in a table from my backend
    s

    Solemensis

    01/22/2023, 5:35 PM
    how can i listen to changes in a supabase table, and then re-fetch new data to my backend and then to my frontend automatically? I'm using nuxt3 server routes as the backend, and there's a library for js named pg-listen. What can be the best way to do this kind of db-change listening with nuxt?
    j
    • 2
    • 1
  • How can I check the environment from a database function?
    h

    HTMHell

    01/22/2023, 5:35 PM
    Hi, I want to have a database function that sends an HTTP request depending on the environment. The reason is: I have an edge function I want to trigger (hence the http request) on a database change (insert), and the URLs are different for local and production. I guess I can create a new table and store a different value for each environment, but I'm wondering if there is a more elegant solution
    g
    • 2
    • 1
  • Subquery select many to one.
    t

    Tristyn

    01/22/2023, 6:15 PM
    I have a Foreign Key relation of many to one. Many Cars to one Person. If I do a select on the Person table, how to I join the Cars which are joined to the person table with a FK? I know Supabase does not support sub queries and there are database functions. However database functions are not ready for production. Any thoughts?
    g
    g
    • 3
    • 21
  • Can't Get Auth UI to Work on Next.JS 13
    a

    alexanderwford

    01/22/2023, 6:18 PM
    Hey team, I have auth "working" on my site in general, but now I'm trying to build a login page, and I can't get it to work at all. I'm attaching a screenshot of my code. When I view this page in a browser where I'm already authenticated, it shows with styles, but I get Hydration errors related to Invalid DOM properties. However, the login form "works" in that it returns an access_token, but it doesn't let me into my site and doesn't redirect properly. Then, the CSS breaks, it looks all white, and the form no longer works. In a browser session where I've not logged in ahead of time, it simply starts with the broken white-looking version and does nothing and goes nowhere. I've looked up every tutorial I can find, and there's nothing I can see that would cause either of these problems. Any help you can offer is greatly appreciated.
    • 1
    • 3
  • Is there a way to make the make Supabase Auth Ui React use popup for third party logins?
    c

    Cabtn

    01/22/2023, 7:57 PM
    Feedback: Love Supabase, docs need some love though. Hey all looking here: https://supabase.com/docs/guides/auth/auth-helpers/auth-ui and trying to see if there is a way to have it so when a user decides to login in with a 3rd party (google) rather than navigating to a new page just having a popup window. Closest things I found to docs was here: https://github.com/supabase/ui/blob/master/src/components/Auth/Auth.tsx but didn't see any props that would support popups.
    t
    • 2
    • 1
  • Send an HTTP request to a local edge function via pg_net
    h

    HTMHell

    01/22/2023, 8:01 PM
    I created a database function that is being called via a trigger. In the function I send a POST request to my local edge function that is running. I tried both
    54321
    and
    8000
    ports.
    Copy code
    perform
      net.http_post(
        url:='http://localhost:8000/functions/v1/myfunction',
        body:='{}'::jsonb
      ) as request_id;
    But I am not receiving the request. When I use an external URL, it works. (I used beeceptor.com to check) What is wrong?
    g
    • 2
    • 8
  • too many values to unpack (expected 2)
    v

    ven

    01/22/2023, 8:44 PM
    I am trying to connect to my database using pgAdmin 4 and I keep getting this error. Have attached the error snapshot. However I am able to see my tables and data from the Supabase studio.
  • Using Redis in an Edge function
    e

    Eythor

    01/22/2023, 10:29 PM
    Hi, I am trying to connect a client to a redis server in an edge function but I am having difficulty getting it to connect. When calling the function it takes a long time to respond and finally it returns a 500 http error and where the function is running I get this error message.
    Copy code
    ConnectionRefused: Connection refused (os error 111)
        at async Object.connect (deno:ext/net/01_net.js:353:46)
        at async RedisConnection.#connect (https://deno.land/x/redis@v0.29.0/connection.ts:166:11)
        at async RedisConnection.#connect (https://deno.land/x/redis@v0.29.0/connection.ts:196:7)
    I have tried a local redis server instance and a deployed instance but I have the same problem with both. I used the following command to host to function locally
    supabase functions serve redisTest
    I tried running the connection command directly with deno and then I had to add
    --allow-net
    parameter and then it to worked well, can I somehow add that parameter to the edge function? The code I am using inside the function looks like this `import { serve } from "https://deno.land/std@0.168.0/http/server.ts"; import { connect } from 'https://deno.land/x/redis/mod.ts'; serve(async (req) => { const { param } = await req.json(); const redis = await connect({ hostname: "localhost", port: 6379, }); const value = await redis.get(param); const data = { message:
    ${param} is ${value}
    , } return new Response( JSON.stringify(data), { headers: { "Content-Type": "application/json" } }, ) })` Do you know what I might be doing wrong?
    a
    • 2
    • 3
  • Need help with demo db
    r

    RevUp

    01/22/2023, 10:30 PM
    I'm new to Supabase and trying to setup this demo: https://github.com/xulioc/sveltekit-supabase-dashboard I'm stuck at the step "Execute init_databse.sql and init_demo_data.sql in Supabase SQL Editor." and not sure if I should just create a table in Supabase for each of the two sql files. When I try to do that and click "RUN" it keeps giving me the error: "Failed to run sql query: relation "orgs" does not exist" Any help would be very much appreciated! 😉
    s
    • 2
    • 5
  • simple insert returns - "more than one row returned by a subquery used as an expression"
    c

    Cardoso

    01/22/2023, 11:03 PM
    Copy code
    const addReview = async (review: Omit<Review, "created_at" | "updated_at">, stayId: string) => {
        const { data, error } = await supabaseClient
          .from<"reviews", Reviews>(REVIEWS_TABLE_NAME)
          .insert({ ...review, stay_id: stayId })
          .select()
          .single();
    It is the same code as another insert i have for another table. for the other table is OK but for this i have this strange error. no RLS and same error removing the select() + single()
    g
    • 2
    • 7
  • Supabase Auth - Next13 (server components) - Hydration Issues
    d

    Drew

    01/22/2023, 11:52 PM
    After following to documentation with regards to implement supabase Auth with Next13 I find myself getting the following errors. https://supabase.com/docs/guides/auth/auth-helpers/nextjs-server-components Errors: > Warning: An error occurred during hydration. The server HTML was replaced with client content in #document. > Warning: You are accessing "digest" from the errorInfo object passed to onRecoverableError. This property is deprecated and will be removed in a future version of React. To access the digest of an Error look for this property on the Error instance itself. > > Uncaught Error: Hydration failed because the initial UI does not match what was rendered on the server. Has anyone encounter these when trying to run Auth with the new server components?
    a
    • 2
    • 4
  • Strange Heisenbug in Supabase Auth example repo
    s

    sean.s

    01/23/2023, 12:11 AM
    I'm trying to get Supabase's Auth UI working in Next.js with Twitter Oauth login. I've cloned https://github.com/supabase/auth-helpers/tree/main/examples/nextjs and swapped out Github login for Twitter, but otherwise just running the example as is. When I try to login with Twitter oauth, it properly redirects back to localhost with a fragment in the URL that has access_token, etc. and then the page refreshes and removes the fragment. After the page refresh, I am not logged in. If I just open the inspector, however, I am properly logged in after the page refresh. This seems like a bug in the
    Auth
    library, but I'm not really sure how to investigate further. Here's a video demo'ing the behavior. Happy to share the code diff from the example as well if that's helpful.
  • Signing up new users via API does not save them to user table - Do SQL Functions need to be run?
    c

    codeless_tinker_bot

    01/23/2023, 2:07 AM
    I'm not able to add new users to the standard user table after the Sign Up API Endpoint is successfully queried. The calls themselves return with 200 and I see the users in the Auth section of Supabase, but they are not auto added to the user table.
    g
    j
    • 3
    • 5
  • Redirect URLs on self-hosted
    q

    QueueBot

    01/23/2023, 2:27 AM
    I set the environment variable
    ADDITIONAL_REDIRECT_URLS='http://localhost:3000'
    and that doesn't seem to work when I call
    client.auth.signInWithOTP({email: email, options: {emailRedirectTo: 'http://localhost:3000'}})
    (it just redirects to the base
    SITE_URL
    ). Thoughts?
    s
    • 2
    • 3
  • Possible to use a trigger to update a row that is using RLS?
    c

    Cody

    01/23/2023, 4:07 AM
    I'm trying to create a trigger that is run after the
    auth.users
    table is updated. Specifically when I update the
    auth.users
    email
    , I would like it to update the
    email
    column within
    public.profiles
    . I have an RLS policy on
    public.profiles
    that only allows an authenticated user to update their own profile. When when the trigger runs the function:
    Copy code
    sql
    begin
      update public.profiles set email = new.email
      where new.id = id and email != new.email;
      return new;
    end;
    When the trigger runs, I get the following error in my logs
    Copy code
    Database error updating user for recovery: ERROR: permission denied for table profiles (SQLSTATE 42501)
    What would be the best way to do this?
    • 1
    • 1
  • Database function for read, Edge function for write
    c

    CMG

    01/23/2023, 5:06 AM
    I'm having a lot of trouble using RLS for write access. All of the validations and logic checks are not easy to wrap my head around. So my idea is to use database functions for reading (select) data, and edge functions for write (C UD) data because it's much easier to validate requests in typescript. What is the downside of this?
    g
    • 2
    • 1
  • Can we read the data returned by an edge function with an error?
    c

    cohlar

    01/23/2023, 6:00 AM
    Hi, I'm using edge functions as proxies to make external API calls - for this example, my edge function adds a private API key to frontend's requests, makes the API call and sends back the response / data from the request to the frontend. My problem is when my edge function returns a non
    2XX
    status, I am unable to read the data returned by the API with the supabase client. My
    some-api-proxy
    function looks like this (I have removed CORS-related code for simplification):
    Copy code
    ts
    import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
    
    const someApiKey = Deno.env.get('SOME_API_KEY');
    
    serve(async (req) => {
      try {
        if (!someApiKey) {
          return new Response(JSON.stringify({ message: 'Some API key not configured.' }), { headers, status: 500 });
        }
        const { path, params, init } = await req.json();
        const response = await fetch(`https://api.some.com/${path}?${new URLSearchParams({ ...params, key: someApiKey })}`, init);
        const data = await response.json();
        return new Response(JSON.stringify(data), { headers, status: response.status, statusText: response.statusText });
      } catch (error) {
        return new Response(error.message, { headers, status: 400 });
      }
    });
    And I am calling the edge function with the supabase client as follows:
    Copy code
    ts
    const body = { path: 'somePath', params: someParams, init: someInit };
    const { data, error } = await supabase.functions.invoke('some-api-proxy', { body: JSON.stringify(body) });
    if (error) {
      // Here I have access to the error context (of type Response), i.e. status, statusText
      // But I cannot access the data itself. I have tried `await error.context.json()`, the promise never seems to resolve
    };
    // Here I have access to the data as long as status code is 2XX
    Some APIs have token buckets, and return meaningful data together with the error, such as how many tokens remain and at what rate those tokens refill.
    s
    • 2
    • 4
  • can you resolve relations in payload?
    r

    rinorzk

    01/23/2023, 7:35 AM
    So I have a simple chat room, and each message can have a reply_id, which is a relation to another message. And while I have the real time enabled for this messages table, when I get the payload I just insert the new message from payload into the list of messages. While this works great for regular messages, I would like to have the resolved payload for the reply_id. I can ofc do this when I get messages directly with:
    Copy code
    js
    const { data, error } = await supabaseClient
        .from<RoomMessage>("room_messages")
        .select("*, profile: profiles(username), replyOf: reply_id(content)")
        .eq("room_id", roomId)
        .order("created_at", { ascending: true });
    I was wondering if I can have something similar when getting the new payload from the subscription? Thanks
    s
    g
    • 3
    • 6
  • @supabase/supabase-js automatically includes node/types.
    i

    IdkWhatever69

    01/23/2023, 7:41 AM
    this is unwanted as some of my types.d.ts conflicts with node/types
    • 1
    • 2
  • Unable to insert rows and no errors are being thrown
    e

    eggnog.

    01/23/2023, 7:45 AM
    Currently trying to create a row in my users table whenever a user signs up and I have tried both insert and upsert in my flutter code and it seems that it does literally nothing and throws zero errors and I have no clue why. i was able to get this to work a few weeks ago but unfortunately dont remember my exact code as I got rid of it. either way I have no clue why my current method is not working and I was hoping it would at least throw an error but it doesnt.
    Copy code
    dart
    supabase.from('users')
      .insert({
        'email': email,
        'display_name': displayName,
      });
    this is literally what im running and it seems to be getting skipped over as there is never an error thrown and the code directly after runs perfectly fine... RLS policy shouldn't be an issue as I know that is set up as I need it and also it would throw an error anyway if I was running into that.
    j
    s
    g
    • 4
    • 30
  • create new column based on existing column's value in database
    l

    Lois

    01/23/2023, 8:38 AM
    Hey team, I already have a table with some existing columns, and I want to create a new column based on an existing column's value, say slicing the string(10), can I achieve that within default value expression? As the input field of default value is quite short/brief.
    s
    g
    • 3
    • 3
1...105106107...230Latest