https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Realtime
    a

    al3x

    09/15/2022, 9:51 PM
    Hello, some questions about realtime: - Hosting: is it possible to host a realtime handler for postgres changes (https://supabase.com/docs/guides/realtime/postgres-changes) as a edge function? Otherwise what hosting do you recommend? - Reliability: how to know if all postgres changes events have been successfully received? Is it possible to replay them during downtime for example? Thanks
    g
    • 2
    • 1
  • Securing access to database functions only
    t

    thestepafter

    09/15/2022, 10:00 PM
    I am considering only having database functions in the public schema to ensure that the frontend application we are building receives very specific data already formatted as JSON. My hope is to prevent any direct table access through the API which reduces the number of decisions my frontend team needs to make. This should also prevent n+1 queries and any other performance issues that may happen when calling the API using JS. My question is, if I provide access using RLS to the underlying tables in a different schema to my users with the idea that they will only access the data using the database functions, is it possible for those users to access the direct tables in the non-public tables through the API?
    g
    s
    • 3
    • 9
  • Syntax error in postgress functions
    j

    JuicyBenjamin

    09/15/2022, 10:10 PM
    Hi there, I'm very new to this whole database thing and thought that supabase seemed not so intimidating. I am however running into a problem. I'm following this tutorial

    https://www.youtube.com/watch?v=I6nnp9AINJkโ–พ

    because just like he shows in the video I want to increment a value. I'm pretty sure I've followed the guide to a tee, yet supabase is giving me a syntax error and it's really not that helpful because it's just saying at or around variable name. Maybe one of the more advanced users could point out where the problem occurs ๐Ÿ™
    Copy code
    postgres
    declare
      new_amount int;
    begin 
      select amount 
      into new_amount
      from public.collection
      where id = card_id
    
      new_amount = new_amount + 1;
    
      update public.collection
      set amount = new_amount
      where id = card_id;
    
      return new_amount;
    end
    I've set the argument to be card_id. The specific error is: Failed to create function: failed to create pg.functions: syntax error at or near "new_amount"
    t
    g
    • 3
    • 69
  • Documentation on stripe in edge function does not match implementation resulting in error.
    t

    Tony_n

    09/15/2022, 11:04 PM
    I have reduced my edge function to just importing stripe and then creating the stripe client. This throws an error in the edge function that says serve has already been declared.
    Copy code
    import { serve } from "https://deno.land/std@0.131.0/http/server.ts";
    import Stripe from "https://esm.sh/stripe?target=deno&no-check";
    // import { getAccountLink } from '../shared/index.ts';
    
    serve(async (req) => {
      const stripe = Stripe(Deno.env.get("STRIPE_API_KEY") ?? "", {
        // This is needed to use the Fetch API rather than relying on the Node http
        // package.
        httpClient: Stripe.createFetchHttpClient(),
        apiVersion: "2020-08-27",
      });
      // console.log(stripe)
      return new Response(
        JSON.stringify({ accountLink: 'https://google.com' }),
        { headers: { "Content-Type": "application/json" }, status: 200, statusText: 'OK' },
      )
    })
    • 1
    • 4
  • Edge Function execution time limit
    b

    Bicijay

    09/15/2022, 11:06 PM
    Hey guys, i have a node API with a single endpoint and i was wondering if i could move it to Supabase Edge Functions. Its pretty much a endpoint where the user can upload a image to the server for compression with sharp.js and upload it to s3. Is there a time limit for the function execution, should this use case be okay?
    g
    • 2
    • 1
  • magiclink auth returns error `url argument is missing`
    s

    Scott

    09/15/2022, 11:25 PM
    I am getting the error
    url argument is missing
    when trying to use
    supabaseClient.auth.signIn()
    with a magiclink/otp. I get this error in the supabase-js client, but oddly enough the same error occurs when using the Supabase UI to send a magiclink for a user. This used to work, but I changed my Site URL and it stopped working afterwards. I'm not sure what's wrong, I can't seem to find this error in the docs anywhere.
    g
    n
    • 3
    • 2
  • How to verify google oauth using supabase?
    a

    aleemrehmtulla

    09/16/2022, 1:01 AM
    Hey! I want my own domain to show when going through google oauth, how should I go abouts it? It asks me to verify I own the callback URL :( Most intuitive solution would be to just setup a redirect of
    mydomain.com/callbackurl
    that goes to the supabase. Is there any better way? What's official way to do so :)
    s
    f
    • 3
    • 3
  • supabase.auth.signIn is not a function
    j

    jyn

    09/16/2022, 1:47 AM
    Most likely a stupid, stupid question. Apologies in advance. Problem: when calling supabase.auth.signIn({...}), error "supabase.auth.signIn is not a function" is thrown. Background: I went through the quick start here https://supabase.com/docs/guides/with-react and could work with the magic link without issue. Decided to try email sign in. Both supabase.auth.signIn and supabase.auth.session() throw the error as described above as I'm trying to sign in/check the session with email log in. I moved my createClient() code to the same react file instead of importing, same issue. I've went through a number of forum posts/youtube tutorials looking for a solution, but most seem to be using similar code to me without issue. Would really appreciate any help on this.
    j
    • 2
    • 3
  • Realtime Typescript Types
    t

    Teiem

    09/16/2022, 4:40 AM
    Hey, how can you use Typescript in combination with realtime to get typed arguments for the callback?
    Copy code
    const channel = supabase
        .channel("public:channelName")
        .on(
            "postgres_changes",
            {
                event: "INSERT",
                schema: "public",
                table: "channelName"
            },
            (payload) => {
                console.log("INSERT", payload);
            })
        .subscribe();
    In this case
    payload
    has the type
    any
    . I did pass my Typescript definitions to the constructor when creating the
    SupabaseClient
    (
    const supabase = createClient<Database>
    ) and get correct types for normal queries.
    • 1
    • 1
  • Next.js and Supabase v2
    m

    Mathiassio

    09/16/2022, 4:44 AM
    I'm trying to give Supabase another shot, and I was wondering how well the @supabase/auth-helpers-nextjs is working with the Supabase v2? Last time I tried it wasn't updated and I find sometimes that Supabase and Next.js was hard to get up an running with user authentication across the app. I
    a
    • 2
    • 1
  • Bucket Policies keep on error
    i

    Indra Zulfi

    09/16/2022, 4:48 AM
    Hey folks, I am trying to upload image to bucket but the console saying it's error.
    Copy code
    new row violates row-level security policy for table "objects
    All policies have been setup. But the issue still persist.
    t
    • 2
    • 1
  • Adding a new Auth provider
    c

    cataxcab

    09/16/2022, 8:12 AM
    Hi, I need a new Auth provider, Zoho(https://www.zoho.com/). I plan on implementing and submitting a PR myself. I went through these suggestions in Contributing.md: https://github.com/supabase/gotrue/blob/master/CONTRIBUTING.md#guidelines-for-implementing-additional-oauth-providers. Apart from that is there something I should know? Should I create an issue first and wait for permission before submitting my PR?
  • storage egress
    t

    tonyhart

    09/16/2022, 8:34 AM
    seems storage egress is way too small is outsource storage to s3/wasabi available right now ?? if not, is storage api support load thumbnail for images ? for smaller and efficient data transfer
    g
    • 2
    • 6
  • RLS on INSERT with linking table
    f

    FunHellion

    09/16/2022, 10:09 AM
    Hi there, Everyone should be able to insert into a table but only select if they have an entry in the linking table. The issue here is that I need the team_id for the insert in the linking table (team_members). I've been searching the internet for the answer but I can't seem to find it. My table structure is as follows: teams members RLS statements on teams: INSERT
    true
    SELECT
    Copy code
    (uid() IN ( SELECT team_members.user_id
       FROM team_members
      WHERE (team_members.team_id = teams.id)))
    Hopefully someone can help me with this, thanks in advance!
  • SMTP with Effective-functions
    s

    Showdey

    09/16/2022, 10:41 AM
    Hi, I want to use email functionality in functions but all ports used for smtp are blocked and Iโ€™m getting time-out errors. Is there a way to unlock them? Or what can I do
    n
    • 2
    • 2
  • Import from SQL to Supabase
    x

    xerox_04

    09/16/2022, 11:45 AM
    Hello there! I have a SQL Server database that is modified every three months (some rows are erased). So far I ran a query in SQL, downloaded and stored the Excel files (no more than 5 MB each, in total 20 MB annually) but I don't want to make it manually. I need a way to automatically import the original data into supabase. I want to query the last three months of data, and add it to the online database automatically (some kind of Cron job or something similar). What would be the easiest option? Thanks in advance! ๐Ÿ™‚
    t
    j
    • 3
    • 11
  • Connection Pooling with PgBouncer
    m

    mohammed-io

    09/16/2022, 1:21 PM
    Hello everyone, I need to connect directly to the Postgres DB provided by Supabase in a serverless function, I can see it supports PgBouncer there How can I connect to the pgbouncer and make use of that? Is it by a normal PgConnection string? Do I need to use
    PgPool
    from
    pg
    package on Node js?
    g
    • 2
    • 6
  • How do I delete the first row and return without condition
    c

    chientrm

    09/16/2022, 1:43 PM
    How do I delete the first row and return without condition
    g
    • 2
    • 5
  • POST to endpoint returning 201 but no new DB row?
    c

    Chuckatron

    09/16/2022, 1:46 PM
    I've also posted this to GitHub before spotting the Discord server, so feel free to delete this if that is the correct place for this question. I'm just getting to grips with Supabase, loving it so far. I've got a test table lists which a couple of columns, id & name. My understanding is that this should create the appropriate CRUD endpoints. When I make a GET request on /rest/v1/lists I do indeed get the rows I expect. However, submitting a POST with a valid body (excluding ID as it looks as though this is autoincrementing) to the same endpoint returns a 201, but a new row is not created in my DB. Does anyone have any idea what I'm doing wrong? If I wasn't getting a 201 I'd think something is amiss, but apart from no new row being created, all seems fine! Any help that anyone can offer would be great, thanks!
    n
    g
    • 3
    • 27
  • Image upload taking too long
    m

    MrSARS

    09/16/2022, 1:56 PM
    I am upload an image to an image bucket on supabase. And the 1 image file which is 56.13KB is taking quite a long while to upload, is there a fix of this? As of the time of this post, file is still being uploaded
    g
    • 2
    • 16
  • Realtime not working properly
    d

    DarthJarJar

    09/16/2022, 2:07 PM
    I have a simple subscription, but it only works like 60% the time. I have not yet been able to identify the specific cases where it fails, as of now it just seems to be random Here's the code
    Copy code
    js
     const mySubscription = supabase
      .from('testlist')
      .on('*', (payload) => {
        console.log('Change received!', payload)
        if (payload.eventType === "INSERT") {
          datalist = [...datalist, payload.new]
        } 
        if (payload.eventType === "DELETE") {
          console.log(datalist.indexOf(payload.old))
          removeFromDataList(payload.old.id)
          console.log(datalist)
          datalist = datalist
        }
        
      })
      .subscribe()
    g
    • 2
    • 16
  • Getting Started with Supabase in Docker
    s

    silvanet

    09/16/2022, 2:36 PM
    I'm following the guide on Self-hosting with Docker. When I fire it up the Supabase portal that it shows on localhost:3000 is not my account. It has a Logout button but I can't log out. It is stuck on connecting to a Default Project in a Default Organization. Where do I fix this?
    • 1
    • 2
  • Rapidly firing subscriptions question.
    g

    gesusc

    09/16/2022, 4:10 PM
    We currently are looking to migrate from Firebase to Supabase but our realtime watchers don't easily map over to Supabase subscriptions due to their limitation of only allowing a single filter. If we switched to a single subscription but that subscription was on a set of data shared by 1 to many users would there be any concerns if it was constantly firing? Our app is a collaborative text editing tool so as a user writes in a document those changes are stored on the backend in a single table. As you can imagine if many users are all writing at the same time (with some writing on different documents) data could be constantly being written and if a single client listens to all changes the websocket could be firing non-stop. With a good number of those triggers being for data one client might not even care about based on where they are in the UI. That seems like it would not be ideal but due to the one filter limitation on Supabase subscriptions it's kind of our only options. Unless we switch to polling for changed data which has its own set of complexities.
    g
    • 2
    • 15
  • script tag html
    j

    Jonathan_Nathan

    09/16/2022, 7:18 PM
    how can i create a login button on my website
    g
    • 2
    • 1
  • High network latency on supabase response
    r

    rishav

    09/16/2022, 8:15 PM
    Hi. I am using supabase for a simple test project and my serevr is getting response latency of 1-2 seconds. I only have 7 entries in my query table, so I think its due to the network hops. Is there a way to improve this time. Generally I would have expected network latency to be in the order of a few 100 ms. Also on a related note - how does scaling works in Supabase? Can I create read replicas in different regions?
  • Value is only updating when I switch tabs
    n

    Nin

    09/16/2022, 9:13 PM
    Copy code
    useEffect(() => {
        if (user) {
          const subscription = supabase
            .from(`profile:id=eq.${user.id}`)
            .on("UPDATE", (payload) => {
              setUser({ ...user, ...payload.new });
            })
            .subscribe();
    
          return () => {
            supabase.removeSubscription(subscription);
          };
        }
      }, [user]);
    Above is my code, the value is only updating when the screen goes out of focus and I have no idea what this is? Attached is a GIF that shows my screen. I don't understand what's wrong?
    g
    • 2
    • 57
  • Supabase returning 400 on PUT auth v1 user
    u

    [GodderE2D]

    09/16/2022, 11:14 PM
    Everything was working fine yesterday, I didn't touch my code or anything, but today when using
    supabase-js@1.35.4
    , Supabase returned a 400 error on
    PUT /auth/v1/user
    . I was trying to edit user metadata in my database. Not using prisma. Client code: (React 17 with Next 12)
    Copy code
    ts
      const [title, setTitle] = useState("");
      const [description, setDescription] = useState("");
      const [slug, setSlug] = useState("");
      const [tags, setTags] = useState<string[]>([]);
      const [content, setContent] = useState("");
      const [contentMode, setContentMode] = useState("code");
      const [MDXContent, setMDXContent] = useState<MDXContent>();
    
      useEffect(() => {
        const interval = setInterval(async () => {
          if (!title && !description && !slug && !tags.length && !content) return;
    
          if (title === supabase.auth.user()?.user_metadata.title) return;
          if (description === supabase.auth.user()?.user_metadata.description)
            return;
          if (slug === supabase.auth.user()?.user_metadata.slug) return;
          if (tags === supabase.auth.user()?.user_metadata.tags) return;
          if (content === supabase.auth.user()?.user_metadata.content) return;
    
          const { error } = await supabase.auth.update({
            data: {
              blogDraft: {
                title,
                description,
                slug,
                tags,
                content,
              },
            },
          });
    
          if (error) {
            console.error(error);
            toast.error(
              "An unexpected error occurred while saving a draft. Refer to the console for details."
            );
          }
        }, 5000);
    
        return () => clearInterval(interval);
      }, [title, description, slug, tags, content]);
    Server API log: - Status: 400 - Method: PUT - Timestamp: 1663368211264000 - Client: supabase-js/1.35.4 - Referer: Request body:
    Copy code
    json
    {
      "cf": [
        {
          "asOrganization": "Verizon Fios",
          "asn": 701,
          "botManagement": [
            {
              "score": 98,
              "staticResource": false,
              "verifiedBot": false
            }
          ],
          "city": "XXX",
          "clientAcceptEncoding": "gzip, deflate, br",
          "clientTcpRtt": null,
          "clientTrustScore": 98,
          "colo": "XXX",
          "continent": "NA",
          "country": "US",
          "edgeRequestKeepAliveStatus": 1,
          "httpProtocol": "HTTP/3",
          "isEUCountry": null,
          "latitude": "XXX",
          "longitude": "XXX",
          "metroCode": "XXX",
          "postalCode": "XXX",
          "region": "XXX",
          "regionCode": "XXX",
          "requestPriority": null,
          "timezone": "America/New_York",
          "tlsCipher": "AEAD-AES128-GCM-SHA256",
          "tlsClientAuth": [
            {
              "certPresented": "0",
              "certRevoked": "0",
              "certVerified": "NONE"
            }
          ],
          "tlsExportedAuthenticator": [
            {
              "clientFinished": "XXX",
              "clientHandshake": "XXX",
              "serverFinished": "XXX",
              "serverHandshake": "XXX"
            }
          ],
          "tlsVersion": "TLSv1.3"
        }
      ],
      "headers": [
        {
          "accept": "*/*",
          "cf_connecting_ip": "XXX",
          "cf_ipcountry": "US",
          "cf_ray": "74bd1f181ed67fed",
          "content_length": "518",
          "content_range": null,
          "content_type": "text/plain;charset=UTF-8",
          "date": null,
          "host": "mqzswyobtehomvpicltf.supabase.co",
          "referer": "https://www.godder.xyz/",
          "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36",
          "x_client_info": "supabase-js/1.35.4",
          "x_forwarded_proto": "https",
          "x_forwarded_user_agent": null,
          "x_real_ip": "XXX"
        }
      ],
      "host": "mqzswyobtehomvpicltf.supabase.co",
      "method": "PUT",
      "path": "/auth/v1/user",
      "protocol": "https:",
      "sb": [
        {
          "auth_user": "b9d73cee-2922-4daa-9cfb-bb6701f65ce3"
        }
      ],
      "search": null,
      "url": "https://mqzswyobtehomvpicltf.supabase.co/auth/v1/user"
    }
    g
    • 2
    • 7
  • Can I get loading state from data fetch?
    b

    Bee

    09/16/2022, 11:26 PM
    Hello, I was wondering if I could grab the loading state of a fetch so I can make some loading ui. I tried
    Copy code
    const { data, error, loading } = await supabase
                .from('posts')
                .select()
     if(loading){
                console.log("loading")
    }
    But this didn't seem to return loading at all even when it was clear data was loading. I don't see loading anywhere in the docs so not sure if it's doable or not.
    j
    j
    p
    • 4
    • 8
  • Filtering by foreign key & .or
    m

    mansedan

    09/17/2022, 7:16 AM
    Hey all, We are trying to effect a query by checking for a
    ilike
    match in either column (home_team or away_team) both serving as a Foreign Key to the same table. We are trying like this:
    Copy code
    js
    const { data, error } = await supabaseClient.from('table').select(`home_team!inner(*),away_team!inner(*)`).or(`mascot.ilike.%${q}%`, { foreignTable: 'home_team' }).or(`mascot.ilike.%${q}%`, { foreignTable: 'away_team' })
    and
    Copy code
    js
    const { data, error } = await supabaseClient.from('table').select(`home_team!inner(*),away_team!inner(*)`).or(`mascot.ilike.%${q}%`, { foreignTable: ['home_team', 'away_team'] })
    With no real luck. Is there a way to do the query we are attempting?
    g
    • 2
    • 4
  • AuthRetryableFetchError on inviteUserByEmail()
    n

    nickreed

    09/17/2022, 8:12 AM
    I can successfully run
    auth.admin.listUsers
    , so it seems like I have the client setup with the correct full-permission service role token, but I get an error that I cant figure out when trying to inviteUserbyEmail (
    AuthRetryableFetchError {"size":0,"timeout":0}
    ) . My code for listing/importing, using
    @supabase/supabase-js@2.0.0-rc.10
    Copy code
    const rootSupabase = createClient(
      process.env.SUPABASE_URL,
      process.env.SUPABASE_SECRET_SERVICE_ROLE,
    );
    
    const {
      data: { users },
      error: usersError,
    } = await rootSupabase.auth.admin.listUsers();
    console.log({ users, usersError });
    if (usersError) {
      throw new Error(usersError);
    }
    
    const { data: inviteData, error: inviteError } =
      await rootSupabase.auth.admin.inviteUserByEmail(email);
    
    if (inviteError) {
      throw new Error(inviteError);
    }
    
    console.log('inviteData:', inviteData);
    stack trace:
    Copy code
    AuthRetryableFetchError: {"size":0,"timeout":0}
        at /Users/nickreed/code/voiplabs/callingio-api/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:33:16
        at Generator.next (<anonymous>)
        at /Users/nickreed/code/voiplabs/callingio-api/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:8:71
        at new Promise (<anonymous>)
        at __awaiter (/Users/nickreed/code/voiplabs/callingio-api/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:4:12)
        at handleError (/Users/nickreed/code/voiplabs/callingio-api/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:27:40)
        at /Users/nickreed/code/voiplabs/callingio-api/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:86:35
    • 1
    • 1
1...242526...230Latest