https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Bucket content not showing
    e

    eloahsam

    03/18/2023, 7:32 PM
    Today ive been trying to access my buckets content but it keeps loading on the supabase web dashboard and never showing anything, when i inspect the page i see on error on the ..list api... -> "{"message":"id must match /^[a-z0-9-\\.]+$/ regular expression"}" But from my nexjs app i can using the js sdk i get no errors so the error is on Supabase UI, i tried removing my cache etc but nothing fixes the problem , is anyone else experiencing the same issue ?
    g
    • 2
    • 15
  • Do you prefer setting up RPC's or just setting up and querying your database from the frontend?
    v

    Vik

    03/18/2023, 7:41 PM
    Curious on what others preferences are in this regard. I'm curious if there any performance differences from doing it either way. Would love to get some more feedback on what others are doing.
  • unable to make changes to public tables
    t

    thosmos

    03/18/2023, 8:06 PM
    I have a few tables that were created by the vercel start template https://github.com/vercel/nextjs-subscription-payments I'm unable to make any changes to those tables or policies with an error about not being the owner. If I log in via psql it says the tables are owned by supabase_admin, but a new table created in the Supabase dashboard is owned by
    postgres
    . Is there a way to change ownership of these tables to postgres? This seems like a bug.
    Copy code
    postgres=> \dt
                    List of relations
     Schema |     Name      | Type  |     Owner      
    --------+---------------+-------+----------------
     public | customers     | table | supabase_admin
     public | dashtest      | table | postgres
     public | prices        | table | supabase_admin
     public | products      | table | supabase_admin
     public | subscriptions | table | supabase_admin
     public | users         | table | supabase_admin
    (6 rows)
    g
    • 2
    • 1
  • Upload folder to bucket
    a

    apost

    03/18/2023, 8:09 PM
    I got an input which users can select a folder of files and folders to upload on a bucket. how can i upload the whole folder to a bucket?
    g
    • 2
    • 2
  • How to use '!inner' to get all posts from followed users?
    v

    Vik

    03/18/2023, 8:44 PM
    I'm trying to create a query to get all the posts from followed users. This is the query to get all posts currently:
    Copy code
    const getPosts = async () => {
      const { data, error } = await supabaseClient
        .from('posts')
        .select('post_id, created_at, content, asset_url, profile:user_id(*)')
        .order('created_at', { ascending: false });
    
      if (error) {
        throw Error(error.message);
      }
    
      return data as unknown as Post[];
    };
    I want to add a filter so I only get the posts from followed users. The relationships table is setup as so:
    Copy code
    approved: boolean;
              created_at: string;
              follow_id: string;
              followee_id: string;
              user_id: string;
    Would love any feedback on this, one thing I haven't mastered. A valid follow is the auth.uid() = followee_id and approved = true.
    g
    g
    • 3
    • 30
  • `TLS connection failed` when connecting to postgres from edge function
    d

    debrijja

    03/18/2023, 10:01 PM
    Hey all, just following the example code from connect to postgres edge function docs. The connection works but I always get this error (which I just ignore in the logs):
    Copy code
    Sending fatal alert BadCertificate
    TLS connection failed with message: invalid peer certificate contents: invalid peer certificate: UnknownIssuer
    Defaulting to non-encrypted connection
    Any way to suppress or fix it? Would still be nice to clean it up so other people checking the logs don't think there's a real problem.
  • FetchError: res.text is not a function
    r

    Raj Bennin

    03/18/2023, 10:21 PM
    Using Node.js, I'm getting this error on inserting a new row and I'm not sure what this means exactly. I've checked the logs, they look ok and all of the row fields except for the id are nullable.
    s
    • 2
    • 1
  • Error when adding a foreign key column
    c

    CELESTIALCITY

    03/19/2023, 3:09 AM
    I want the ``members`` column to be an FKEY array to my public ``users`` table but I keep getting this error
    s
    • 2
    • 1
  • Coalesce in a supabase select
    h

    Hypersigils

    03/19/2023, 3:10 AM
    Quick question--is it possible to use a "coalesce" or similar function for a supabase select statement? For example:
    Copy code
    .from('table')
    .select(`
      id,
      COALESCE(value, other_table.value)
    `);
    s
    • 2
    • 3
  • weird startup issue
    j

    Jinx

    03/19/2023, 4:27 AM
    Whats this
    s
    • 2
    • 1
  • Policy check on reference table
    s

    Simon

    03/19/2023, 5:40 AM
    I have the following policy on WITH CHECK:
    Copy code
    (EXISTS ( SELECT 1
       FROM chat
      WHERE ((chat.id = message.chat_id) AND (chat.user_id = auth.uid()))))
    However it fails on insert. I want to check if the chat which I reference with chat_id really belongs to the current authenticated user.
    • 1
    • 1
  • Custom Backend vs Supabase (BaaS)
    a

    anggoran

    03/19/2023, 6:48 AM
    As the time goes on, Supabase has many features that I think any business scales need. It has Generated API and GUI for Auth, Database, Realtime, etc. And if we want to create a Custom API, we can use Edge Functions that can connect other services outside Supabase. Now I don't get why some people still prefer to create a custom backend from scratch like using Node/Go, cause Supabase already has these features which minimizes cost and time.
    n
    j
    • 3
    • 6
  • Having problems with SQL Editor
    w

    Wamy

    03/19/2023, 7:45 AM
    I want to update the user's metadata when something is modified in the "users" table on public. How would I go about doing this using SQL functions?
    g
    • 2
    • 1
  • Flutter Supabase issue with .signInWithOTP
    a

    alekperos

    03/19/2023, 9:12 AM
    I have set up project in Supabase, Flutter project is set to use the params to initialize Supabase instance, have all the tables etc. SetUp the Twilio integration in order to use for SMS OTP signIn. iOS infolist and Android manifest files all are set up with Redirect URLs etc. but when using the function .signInWithOTP(phone: '') i am getting an error: flutter: Invalid argument(s): No host specified in URI xxxxxxxxxxxyyyyyyyyauth/v1/otp? i am banging my head to resolve this but no luck(((
  • Using Views with Typescript not null issue
    c

    chrismasters

    03/19/2023, 9:43 AM
    Hi, If I have a table called
    playlists
    which has a column called
    first_play
    which is a boolean and not null created with a migration like this
    Copy code
    alter table "public"."playlists" add column "first_play" boolean not null default false;
    Then the generated typescript definition file for the
    playlist
    type looks like this
    Copy code
    play_order: number
    But if I then use this column in a view, ie
    Copy code
    CREATE OR REPLACE VIEW public.tracklists AS
      SELECT
        playlists.first_play AS first_play
      FROM playlists
    Then
    first_play
    in the view type is now nullable ie
    Copy code
    first_play: boolean | null
    Is there a way to prevent this from happening? Thanks!
    s
    • 2
    • 2
  • Allow functions, but block direct table access?
    l

    lea001

    03/19/2023, 11:41 AM
    QUESTION: Is it possible to within the policy model block direct access to the tables, but grant access to custom functions? BACKGROUND: I plan to not login users. Instead block general select and only allow publishing content and receive a share code and then read back the content by providing the share code. Content storage and share code is split into different tables which I don't want to give clients direct access, so I can control the exact allowed interface via PSQL functions. Is that possible?
    n
    g
    • 3
    • 9
  • supabase-js with custom schemas
    g

    gleb

    03/19/2023, 12:18 PM
    Hello, I'm building TypeScript Nextjs app with Supabase. In supabase database I made separate schemas for some data that I'm trying to pull from the client. However, I didn't find a way to pass one or more schema into
    createBrowserSupabaseClient<Database>()
    or
    createServerComponentSupabaseClient()
    in TypeScript.
    g
    • 2
    • 2
  • I want to upgrade to pro, but my site is live and I'm worried about downtime
    b

    bode

    03/19/2023, 2:12 PM
    I'm ready to upgrade to Pro, but will there be any downtime when I pay and have upgraded to Pro? I won't be changing anything else, but I don't want to have to pause the account, or for database transactions to stop working temporarily while we get more storage and more egress and other things.
    n
    • 2
    • 1
  • retrieve session client side?
    c

    chrtravels

    03/19/2023, 3:28 PM
    Hello, How in the world can you retrieve the session client side, in NextJS? Been working on this for eight hours and the best I can do is get a fulfilled promise. I can get it if I use getServerSideProps but I had to make every component a server side. Per the docs:
    Copy code
    const { data, error } = await supabase.auth.getSession()
    However since the client side component isn't async, I put the call to getSession in an async function then called it in a useEffect:
    Copy code
    useEffect(() => {
        setSession(fetchSession().then(data => data));
      }, [])
    All I get in return is
    Copy code
    Promise {<fulfilled>: {…}}
    It works when I do something similar to get a list of posts but not with getting the session. Any thoughts are appreciated.
  • supabaseKey required
    a

    alana

    03/19/2023, 4:04 PM
    i'm adding auth into an existing project and getting this weird error when i try to add to
    _app.tsx
    . i have NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env variables defined in my
    .env.local
    . any ideas what i'm doing wrong?
  • How would you design a quizes database
    f

    funkyj

    03/19/2023, 4:47 PM
    HI, I want to make a quiz that contains a image, text and 4 answers. And make it for example 5 questions long. How should i design the table to make this work. Since i cant make every answer images etc a seperate column. How would you design the database?
    n
    g
    • 3
    • 4
  • useUser is null (createBrowserSupabaseClient vs createServerSupabaseClient)
    s

    spicypete

    03/19/2023, 6:14 PM
    Hi, I am building a simple app with
    next.js
    (SSR off),
    tRPC
    ,
    prisma
    , and
    supabase
    . My server uses
    createServerSupabaseClient
    to get the auth context:
    Copy code
    ts
    // create the ctx variable for each tRPC procedure
    export const createTRPCContext = (_opts: CreateNextContextOptions) => {
      const { req, res } = _opts;
      const supabase = createServerSupabaseClient<Database>({
        req,
        res,
      });
      return {
        supabase,
        ...createInnerTRPCContext({}),
      };
    };
    Which I then use in my tRPC procedures to sign in the user.
    Copy code
    ts
    export const authRouter = createTRPCRouter({
      signIn: publicProcedure
        .input(z.object({ phone: z.string() }))
        .mutation(async ({ ctx, input }) => {
          const { data, error } = await ctx.supabase.auth.signInWithOtp({
            phone: input.phone,
          });
          return { data, error };
        }),
      verify: publicProcedure
        .input(z.object({ phone: z.string(), token: z.string() }))
        .mutation(async ({ input, ctx }) => {
          const { data, error } = await ctx.supabase.auth.verifyOtp({
            phone: input.phone,
            token: input.token,
            type: 'sms',
          });
          // ....
          return { user, session: data.session, error };
        })
    })
    On the frontend, I use
    createBrowserSupabaseClient
    Copy code
    tsx
    // _app.tsx
    
    const App = ({
      Component,
      pageProps,
      router,
    }: AppProps<{initialSession: Session}>) => {
      const [supabaseClient] = useState(() =>
      createBrowserSupabaseClient<Database>({
        supabaseUrl: clientEnv.NEXT_PUBLIC_SUPABASE_URL,
        supabaseKey: clientEnv.NEXT_PUBLIC_SUPABASE_ANON_KEY,
      }));
    
      return (
        <SessionContextProvider
          supabaseClient={supabaseClient}
          initialSession={pageProps.initialSession}
        >
                  <Component {...pageProps} />
        </SessionContextProvider>
       )
    }
    
    export default api.withTRPC(App);
    However, on my auth page,
    • 1
    • 6
  • Method expects to have requestAsyncStorage, none available
    m

    Mohamed Yasser

    03/19/2023, 7:28 PM
    I am facing this error when using const supabase = createServerComponentSupabaseClient({ headers, cookies, }); I think the problem is related to cookies from 'next/headers' but isn't there any other solution to this problem ?
  • is this aasynchronous
    j

    Jinx

    03/19/2023, 7:56 PM
    Is this database asynchronous by default
    g
    e
    • 3
    • 18
  • Reload cache for deno edge functions locally
    i

    imagio

    03/19/2023, 8:24 PM
    I've got some code that I need to load directly from github in my edge functions (because I can't load code from my local pnpm monorepo in them) but there's seemingly no way to force
    supabase functions serve
    to update the Deno cache. My local development is stuck with old cached versions of the files. Deno cache -r locally does not fix it. Since it's run in a docker container I assume it's using a separate cache from my machine. How can I get
    supabase functions serve
    to refresh the Deno cache?
  • Not sure how cookie is being set by Supabase
    d

    DYELbrah

    03/19/2023, 9:51 PM
    I'm using a NextJS application with a TRPC API, where I am handling ALL supabase related calls in the server. As a matter of fact the supabase_url and anon_key are not even exposed to the client. I did not wrap my app.tsx in the SessionContextProvider since I want to do all the session stuff directly from the server. My issue is that I have the following procedure (api route that runs in the server)
    Copy code
    signInWithPasword: publicProcedure
        .input(
          z.object({
            email: z.string().email(),
            password: z.string(),
          })
        )
        .query(async ({ input, ctx }) => {
          const supabase = ctx.supabase;
          const { email, password } = input;
          const {
            data: { user, session },
            error,
          } = await supabase.auth.signInWithPassword({
            email,
            password,
          });
          if (error) {
            throw new TRPCError({
              code: "UNAUTHORIZED",
              message: error.message,
            });
          }
        }),
    Somehow when my client calls this route from the front-end, if the login information is correct. the cookies are somehow being set? I figured I'd have to do that manually, but to my surprise I dont. I don't have any of the supabaseBrowserClient or anything similar in my front-end. How is the cookies being set?
    n
    • 2
    • 20
  • I can't delete a row (status: 204) / Service Role
    a

    Amr

    03/19/2023, 9:52 PM
    I can't delete a row!! I'm using supabase client with service role. Here's the client setup:
    Copy code
    js
    const supabase = createClient(PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE);
    The delete function:
    Copy code
    ts
    async function deleteReservationByRefCode(refCode: string) {
        const deleteQuery = await supabase
            .from('reservations')
            .delete()
            .eq('ref_code', refCode.toUpperCase());
        console.log(deleteQuery);
    
        const selectQuery = await supabase
            .from('reservations')
            .select('id')
            .eq('ref_code', refCode.toUpperCase());
        console.log(selectQuery);
    
        if (deleteQuery.error) {
            console.error(deleteQuery.error);
            return 'Internal error';
        }
    };
    The console output is:
    Copy code
    js
    {
      error: null,
      data: null,
      count: null,
      status: 204,
      statusText: 'No Content'
    }
    {
      error: null,
      data: [ { id: 7 } ],
      count: null,
      status: 200,
      statusText: 'OK'
    }
    The row actually exists, but It can't be deleted!! I also disabled
    RLS
    just in case, and nothing changed!
    o
    • 2
    • 20
  • How do I select from Auth scheme
    s

    Sniped137

    03/19/2023, 10:27 PM
    Does anyone know how id do something like this:
    Copy code
    py
        email_exists = client.auth.table('users').select('*').eq('email', email).execute().get('data', [])
    To access my users table in the auth scheme It works usually for normal tables
    g
    • 2
    • 1
  • Is the `edge-runtime` source code available?
    d

    Dan Rumney

    03/19/2023, 10:28 PM
    I'm trying to debug some issues with serving functions locally and the trial has led to the
    edge-runtime
    but I can` t find a repo for that Is there one?
    g
    • 2
    • 4
  • join different schema syntax?
    d

    dmayo2

    03/19/2023, 10:34 PM
    Is it possible? I can't quite find the correct syntax. Easy when both tables are in the
    public
    schema. Right now I just have two different calls to db, but like to know if one call is doable. Thanks.
    Copy code
    const { data, error } = await supabase
                        .from('auth.users')
                        .select(`email, profiles (first_name, last_name)`)
                        .eq('id', thisUser)
                        .single()
    Error:
    Error fetching user profile: Could not find a relationship between 'auth.users' and 'profiles' in the schema cache
    g
    • 2
    • 2
1...172173174...230Latest