https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Module not found Can't resolve 'encoding' in node fetch
    l

    Lukas

    11/04/2022, 4:48 AM
    For some reason, I'm getting this weird error in supabase. Versions: "@supabase/auth-helpers-nextjs": "^0.4.5", "@supabase/auth-helpers-react": "^0.3.1", "@supabase/supabase-js": "^2.0.5", I'm using nextjs 13 with the beta app directory. Here's my code:
    Copy code
    js
    "use client";
    
    import "./globals.css";
    import { createBrowserSupabaseClient } from "@supabase/auth-helpers-nextjs";
    import { SessionContextProvider } from "@supabase/auth-helpers-react";
    import { useState } from "react";
    
    export default function RootLayout({
        children,
    }: {
        children: React.ReactNode;
    }) {
        const [supabaseClient] = useState(() => createBrowserSupabaseClient());
        return (
            <html lang="en">
                <head>
                    <title>Create Next App</title>
                    <meta name="description" content="Generated by create next app" />
                    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
                    <link rel="icon" href="/favicon.ico" />
                </head>
                <body>
                    <SessionContextProvider
                        supabaseClient={supabaseClient}
                        initialSession={null}
                    >
                        {children}
                    </SessionContextProvider>
                </body>
            </html>
        );
    }
    s
    c
    +2
    • 5
    • 7
  • RLS with a join table
    f

    felsey

    11/04/2022, 7:09 AM
    I can't for the life of me figure this one out 🤦‍♂️ I have a table of for
    lists
    and a table for
    user_list_relations
    . The
    user_list_relations
    table is joined with the
    lists
    table via the list_id. The
    user_list_relations
    table also has a column called
    user_profile_id
    which match the auth.uid(). I need to setup RLS so that a user can read, instert, update, or delete a list if they have a
    user_list_relation
    for that list. I'm assuming the correct order of operations when creating a new list is: 1. Insert a new row for the list 2. Create the user_list_relation using the list_id from the list that was just created. But, I'm not sure how this all comes together with RLS. Let me know what additional info I can provide. Thanks!
    g
    • 2
    • 2
  • Supabase down ?
    k

    Kcrik

    11/04/2022, 8:38 AM
    Hey guys, I don't know where to ask, but we can't login into pour Supabase anymore, as a dev or as a customer. Is Supabase down ?
    n
    b
    s
    • 4
    • 3
  • Generating JWT (Tool missing in docs?)
    b

    bad_advice

    11/04/2022, 11:51 AM
    https://supabase.com/docs/guides/hosting/overview#api-keys Use this tool to generate keys: (Blank) Is the tool missing or am I missing something here?
    s
    g
    • 3
    • 3
  • Supabase JWT auth for own backend API
    q

    quick_piper15

    11/04/2022, 12:41 PM
    Hello, I would like to use Supabase auth for authorizing users into my own api endpoint. I would like to use JWT for that, and as JWTs are already stored in the supabase.auth.session(), I'm considering using these for my own api endpoint. Would it be wise to store the Supabase JWT_SECRET as an ENV variable on my backend?
    g
    n
    b
    • 4
    • 23
  • Redwood Auth with Supabase and Prisma
    p

    PlayWolf

    11/04/2022, 12:51 PM
    Hey there! I recently switched my application to vercel and supabase (note: it is not yet production-ready, still very deep in development). I managed to get vercel and supabase running, I also managed to get RedwoodJS working with supabase. Though I did ran into a "problem": I currently have a
    User
    -Model in my
    prisma.schema
    . Though I did notice that Supabase has their own system for users, which in return allows for authentication with google, github, etc.. I do want to use this, though I am not sure on how I should implement the authentication-logic with Redwood, and how I need to adjust my
    prisma.schema
    to reference users and their data. For reference, here is (a part of) my
    prisma.schema
    -file:
    Copy code
    /// The User model
    model User {
      id                  String    @id @default(cuid())
      email               String    @unique
      username            String    @unique
    
      // Previously used for dbAuth, will be removed.
      hashedPassword      String
      salt                String
      resetToken          String?
      resetTokenExpiresAt DateTime?
    
      artist              Artist?
      createdAt           DateTime  @default(now())
      updatedAt           DateTime  @updatedAt
    }
    
    /// The artist profile of a user. It contains information about tags, commission packages, etc.
    model Artist {
      id          String    @id @default(cuid())
      /// An artist always refers to its user
      user        User      @relation(fields: [userId], references: [id])
      userId      String    @unique
      /// If an artist is well known, he may request a verification, which grants him a verification-badge so users can recognize him
      verified    Boolean   @default(false)
      createdAt   DateTime  @default(now())
      updatedAt   DateTime  @updatedAt
    }
    Do I still need a
    User
    -Model, or would I scrap that entirely? What would the
    Artist
    -Model reference instead? And how would I have to setup the
    api/functions/auth.ts
    from RedwoodJS, so it would work with the users from Supabase? Thanks in Advance!
    n
    • 2
    • 1
  • Connection to Postgres database stopped working
    c

    chrismatic

    11/04/2022, 1:37 PM
    Hello all, first up let me say that I absolutely love the product! I can, however, no longer connect to my Postgres from my machine (no longer = it used to work with these exact credentials):
    Copy code
    psql -h db.jvjklainlryyksyluimc.supabase.co -p 5432 -d postgres -U postgres
    psql: error: connection to server at "db.jvjklainlryyksyluimc.supabase.co" (54.147.142.241), port 5432 failed: Connection refused
            Is the server running on that host and accepting TCP/IP connections?
    The app and supbase dashboard still work and I was also able to connect from a friend's server. Next I ran a traceroute on the IP and successfully got past my home network. Could my IP have been blacklisted somehow? Thanks in advance!
    g
    • 2
    • 2
  • Dashboard stuck on Connecting, API keys invalidated, can't interact with supabase project at all
    g

    gouhst

    11/04/2022, 2:29 PM
    I'm loving supabase! Unfortunately, I woke up this morning to discover that my supabase API keys were invalidated , which is impacting some production functionality. Went to the dashboard to refresh JWT secrets and restart the server. After doing so, many dashboard pages (Table Editor, Sql Editor, Database, Authentication, etc.) get stuck on "Connecting to project", and it's already been 30+ minutes. This issue actually started yesterday, but my API keys were still working then. I got the following error messages in the UI yesterday (but am not getting any today): Attempt to regenerate JWT secrets 1:
    Copy code
    Please try again. If the failures persist, please contact Supabase support with the following details:
    Change tracking ID: fd0d6309-4c12-466e-9ed0-a9a2168e5930
    Error message: failed to update configuration for API services
    Attempt 2:
    Copy code
    Please try again. If the failures persist, please contact Supabase support with the following details:
    Change tracking ID: 4e47b563-8a03-47c3-a783-01d5b26697d7
    Error message: failed to update configuration for API services
    Not sure if relevant, but I was on the free tier and this project was automatically paused before I un-paused it recently. I seem to have found a few others who've reported this issue after being paused and then un-pausing, like here: https://github.com/supabase/supabase/discussions/6637#discussioncomment-2831867. I upgraded to Pro today to see if that would help (hasn't so far yet). This is also the same issue in support tickets 1194082374 and 1191832961. Any help so that I can interact with my supabase project again would be greatly appreciated!
  • How do you use the types mentioned in the docs?
    t

    Thoth Trismegistus

    11/04/2022, 2:54 PM
    Copy code
    ts
    import supabase from '~/lib/supabase'
    import type { Database } from '~/lib/database.types'
    
    async function getMovies() {
      return await supabase.from('movies').select('id, title, actors(*)')
    }
    
    type Actors = Database['public']['Tables']['actors']['Row']
    type MoviesResponse = Awaited<ReturnType<typeof getMovies>>
    type MoviesResponseSuccess = MoviesResponse['data'] & {
      actors: Actors[]
    }
    How do you use this when calling the function?
    f
    • 2
    • 14
  • Remote DB Reset
    b

    brassotron

    11/04/2022, 4:00 PM
    Is there anyway I can perform the equivalent of
    Copy code
    supabase db reset
    on the remote database to wipe it?
    d
    p
    +2
    • 5
    • 18
  • Autocompletion Scripts
    j

    Jingly

    11/04/2022, 4:23 PM
    This might be a dumb question, but I'm not entire sure what "Generate the autocompletion script" means, or what the cli command is trying to accomplish. From the docs I gather that you can create the script for bash/powershell/etc, but not what the generated script will do? I don't have any specific problem with it, but just trying to understand what it does
    f
    • 2
    • 4
  • Subscribe to a channel using a key
    l

    limiteInductive

    11/04/2022, 5:22 PM
    Hi everyone, I have a "results" table that are secured by RLS with the policy where authenticated users can see their own results. I also have a table "tokens" that is used for un-authenticated user to add results using a rpc function that takes the key as an argument. I would like for a un-authenticated user to be able to subscribe to the "results" table by giving the key corresponding the "token" that is related to the result. Do you know if it is possible? Or maybe have an idea on how to "hack around" that difficulty? Thank you for your time
    g
    • 2
    • 46
  • Relationship doesn't work with users table
    t

    Thoth Trismegistus

    11/04/2022, 5:44 PM
    I have tables
    trackings
    with
    user_id
    , and a profiles table with id related to users table. I am trying to query tracking table and get the corresponding profile.
    • 1
    • 3
  • Redux-Query(RTK-query) with supabase
    r

    Ranjeet

    11/04/2022, 6:02 PM
    Hi there, I am having confusion about how to use RTK-query with supabase in NEXTJS with the freedom to use getServerSideProps as well. I am thinking of using fakeBaseQuery as baseQuery in my slice and define async queries and use those exported hooks inside getServerSideProps() wherever needed but i am not sure that i can use hooks inside getServerSideProps(). It'd really awesome if someone could tell me what would be the better approach or point me to some direction. Thanks
  • RLS Policy With Join
    d

    drewbie

    11/04/2022, 7:06 PM
    Trying to follow along the docs with how to create an RLS policy with joins but cant seem to figure it out. I have
    cart_items
    which have a
    product_id
    and an
    account_id
    . the Products table also has an
    account_id
    . I am trying to create an RLS policy on insert so that you cannot add your own products to your cart but this doesn't seem to work. What am I missing . Appreciate the help!
    Copy code
    create policy "Cart items cannot be added for cart account's products"
      ON public.cart_items for INSERT
      to authenticated
      WITH CHECK (
        not exists (
          select 1 from products
          where products.account_id = account_id
        )
      );
    g
    • 2
    • 4
  • Any way to query Supabase from BQ?
    c

    caseycrogers

    11/04/2022, 7:44 PM
    I'm using Firebase analytics for my analytics stats and then exporting the stats to BQ for querying and dashboards. I want to be able to join my analytics data against my production supabase DB, is there a way to create an external connection between BQ and Supabase? As far as I can tell BQ only allows Postgres connections to Google Cloud postgres instances ):
  • doesn't relationship work with users table?
    t

    Thoth Trismegistus

    11/04/2022, 8:04 PM
    I am getting the error
    Copy code
    Verify that 'trackings' and 'users' exist in the schema 'public'
    doesn't relationship works with users table?
    g
    • 2
    • 2
  • How can I write a select statement in V2 that checks if words appear across multiple columns?
    m

    Matt

    11/04/2022, 9:17 PM
    I have a table 'posts'
    Copy code
    title, text
      content, text
      tags, array of text
    if I have a search request with the phase "wow so cool minecraft" it should be able to select a 'post' with these values for example
    Copy code
    title "wow that nice"
      content "this is so cool"
      tags ["minecraft", "gaming"]
    I was trying to use something this, it works for 'title' and 'content', but doesn't search 'tags'
    Copy code
    let { data: posts, error } = await supabase
    .from('posts')
    .select(`*, profiles(*), comments(count)`)
    .textSearch('title, content, tags', `'minecraft'`)
    Also how I can I make it so it doesn't have to match the entire word? Like searching "test" could still match "latest" Thanks
    g
    • 2
    • 1
  • Is it possible to check if someones session has expired?
    d

    Deed

    11/04/2022, 9:21 PM
    Hi, I wanted to check with getSession or some supabase function see if a users session is expired (I have the expiration set). Is there a way to check?
    j
    • 2
    • 11
  • Change table column order
    u

    user8923

    11/04/2022, 9:46 PM
    Is there a way to change the order or columns in the web-based table editor?
    g
    j
    c
    • 4
    • 12
  • Debug RLS
    f

    felsey

    11/04/2022, 9:48 PM
    I have RLS turned on for a table I'm not able to insert a row because it's violating RLS for that table. From what I can tell everything should be working as expected. The policy check is
    (auth.uid() = creator_profile_id)
    and this is the code to create insert a row.
    Copy code
    const { data, error: listError } = await supabase
          .from("lists")
          .insert([
            {
              creator_profile_id: user.id,
              name: listName,
              google_place_id: selectedPlace.placeId,
              google_place_name: selectedPlace.description,
              google_place_types: JSON.stringify(selectedPlace.types),
              photo_url: await getPhoto(selectedPlace?.description),
            },
          ])
          .select("*");
    What's the best way to debug this and figure out why it's saying that
    new row violates row-level security policy for table \"lists\"
    g
    • 2
    • 2
  • what is RLS security ... ?????
    f

    faizan98

    11/04/2022, 10:45 PM
    const data = await supabase.from("test").select("*"); console.log(data); { error: null, data: [], count: null, status: 200, statusText: 'OK' } #885237287280070708
    g
    l
    • 3
    • 2
  • How do I get the id of a deleted user in a trigger function?
    j

    jkohlin

    11/04/2022, 11:32 PM
    When deleting a user I want to clean up all the rows related to that user with a trigger function but I can't find any documentation of how that is done. This is the function I want to invoke but for it to work I need to know the id of the deleted user. It's not
    @id
    🙂 : ``` begin delete from public.bets where user_id=@id; <-- This isn't working delete from public.final_bets where user_id=$id; <-- neither is this delete from public.profiles where id=auth.user.uid; or this for that matter end;
    j
    • 2
    • 1
  • I want to restrict the person who is logged in to only edit their own data - Is RLS the answer?
    c

    Cory

    11/05/2022, 1:34 AM
    I want to restrict the user to only be able to edit their own data. Right now I have a basic RLS policy set up, but I am also passing the user session id to make sure it matches the one in the table. Is this really needed or are they already blocked out?
    n
    • 2
    • 1
  • uploading multiple files
    u

    ((()))

    11/05/2022, 1:36 AM
    How would one go about uploading multiple files to a bucket?
    g
    • 2
    • 2
  • error while Querying foreign tables - JS
    k

    Khalifa007

    11/05/2022, 9:19 AM
    I received an error while getting user data from user table , user_id is linked to users.auth.id . error :
    Copy code
    {error: {code: PGRST200, details: null, hint: Verify that 'users' and 'user_id' exist in the schema 'public' and that there is a foreign key relationship between them. If a new relationship was created, try reloading the schema cache., message: Could not find a relationship between 'users' and 'user_id' in the schema cache}}
    code :
    Copy code
    import { serve } from "https://deno.land/std@0.131.0/http/server.ts"
    import { createClient } from "https://esm.sh/@supabase/supabase-js@2.0.0";
    console.log("Hello from Functions!")
    const SUPABASE_URL = Deno.env.get("SUPABASE_URL");
    const SUPABASE_ANON_KEY = Deno.env.get("SUPABASE_ANON_KEY");
    serve(async (req) => {
      const { user_id } = await req.json()
    
    
      const supabase = createClient(
        SUPABASE_URL!,
        SUPABASE_ANON_KEY!,
        {
          global: {
            headers: { Authorization: req.headers.get("Authorization")! },
          },
        },
      );
    
      const { data, error } = await supabase
      .from("users")
      .select('*,user_id(id)')
      .eq("user_id", user_id)
      .limit(1)
      .single();
      if(error)  return new Response(
        JSON.stringify({error:error}),
        { headers: { "Content-Type": "application/json" } },
      ) 
    
      return new Response(
        JSON.stringify(data),
        { headers: { "Content-Type": "application/json" } },
      )
    })
  • supabaseauth-helpers-nextjs has no exported member named createMiddlewareSupabaseClient
    s

    Solid Snake

    11/05/2022, 11:17 AM
    Hi guys, I used the middleware.ts in the official documentation (https://supabase.com/docs/guides/auth/auth-helpers/nextjs#auth-with-nextjs-middleware) but this error is returned. Any advice?
    n
    • 2
    • 18
  • Mock data from client with jest (supabase.js)
    a

    abdulrahimiliasu

    11/05/2022, 12:12 PM
    How can I mock the data returned from client.from method in supabse javascript client libarary ? This should work, but how can mock the {data} of returned PostgrestQueryBuilder ?
    Copy code
    mockSupabaseClient.from.mockImplementationOnce(("profiles") => {
       return new PostgrestQueryBuilder(url,{})      })
  • URI too long
    m

    Muezz

    11/05/2022, 12:23 PM
    I am trying to bulk insert over 1000 rows from my front-end and I am getting this error:
    Copy code
    E/flutter ( 8376): , code: 414, details: URI Too Long, hint: null)
    E/flutter ( 8376): #0      PostgrestBuilder._parseResponse
    package:postgrest/src/postgrest_builder.dart:251
    E/flutter ( 8376): <asynchronous suspension>
    E/flutter ( 8376): #1      PostgrestBuilder.then
    package:postgrest/src/postgrest_builder.dart:329
    E/flutter ( 8376): <asynchronous suspension>
    E/flutter ( 8376):
    1) Is there a setting within Supabase which I can toggle to allow for such large insertions? 2) If not, is there a solution or a better alternative? 3) Or should I just limit the number of rows that my users will be allowed to upload? In that case, what is the max allowed number for bulk insertion?
  • Can't access a table using RLS.
    i

    Ivan Kartashov

    11/05/2022, 1:12 PM
    Hi! I created two RLS policies: INSERT for authenticated users only and the same for SELECT (check screenshots). Then I try to INSERT a new row into this table and get this error: postgrest.exceptions.APIError: {'code': '42501', 'details': None, 'hint': None, 'message': 'new row violates row-level security policy for table "kisis_forms"'} I use these docs for Supabase Py: https://github.com/supabase-community/supabase-py So initially I create a client:
    Copy code
    python
    from supabase import create_client, Client
    supabase: Client = create_client(url, key)
    
    #Afterwards I do the auth:
    email: str = str(user_mail)
    password: str = str(user_pass)
    supabase.auth.sign_in(email=email, password=password)
    
    #Then I try to INSERT a new row and recieve mentioned error:
    data = supabase.table(table_name).insert({"tg_id": user_id, "name": name}).execute()
    Guys, could you please help me to resolve this?
    g
    • 2
    • 12
1...606162...230Latest