https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Nextjs Auth Helpers getUser returns type any for user and error
    n

    nickbrinser

    08/16/2022, 12:55 AM
    Currently Nextjs auth helpers
    getUser()
    return type is not resolving correctly. In
    const {error, user} = getUser(ctx)
    both error and user have a type of any. Also if this
    getUser()
    is called while not authenticated, user is returned as null and no error is logged. Also made an issue in the repo. https://github.com/supabase/auth-helpers/issues/213
    o
    • 2
    • 5
  • How to to migrate new local db to schema which I have in prod?
    d

    dmytro.eth

    08/16/2022, 7:51 AM
    Hi all, so we have two supabase instances prod and dev. We are developing against dev at the moment. With the release of supabase CLI, it looks like it would be much easier to handle migrations via CLI instead of doing it manually. To enable CLI usage in our project, I'm trying to migrate freshly set local db schema to what we have in dev currently. So we can start developing in local environment and then push db migrations to the dev via generated scripts. I initialiazed a Supabase project in our repo via
    supabase init
    Then I did a schema dump from dev via pg_dump, then created a blank sql migration script via
    supabase migration new
    and put a pgdump result there. How can I apply those scripts to my local supabase instance? I found how to push it to remote, but not to the local
    • 1
    • 4
  • Any guides on superbase with sqlTools in vscode or another desktop sql client?
    p

    Paul AKA TDI

    08/16/2022, 7:56 AM
    Just hoping there may be something
    s
    • 2
    • 2
  • Missing SQL snippets
    a

    apollo79

    08/16/2022, 8:22 AM
    Yesterday, I set up my database with a relatively long SQL query, which I had in a snippet in the SQL Editor in Supabase Studio. Today, this one and all my other snippets are missing. Is this intended?
    s
    • 2
    • 7
  • syncing database causes errors
    a

    apollo79

    08/16/2022, 12:10 PM
    I have my database set up on app.supabase.com and now I want to develop locally, so I started a project using
    supabase init
    , then used
    supabase link
    and now I wanted to use
    supabase db remote commit
    to sync the local database with the remote one. It works, but if the command ran, I can't use
    supabase start
    anymore,
    supabase db reset
    is affected as well. I get this error about a fifty times:
    Copy code
    shell
    ERROR:  current transaction is aborted, commands ignored until end of transaction block
  • Realtime updates not fired but available in websocket
    e

    emilioschepis

    08/16/2022, 12:29 PM
    Hi, I'm currently experiencing a problem where my realtime subscription does not seem to fire the various events (even though I have subscribed to * in my table). However, when analyzing the network tab, I can see the events being received by the websocket. realtime-js is v1.7.4
    g
    p
    p
    • 4
    • 15
  • Listen changes to a specific column
    p

    Pierre_

    08/16/2022, 1:11 PM
    Hello, is it possible to listen for change in realtime for a specific column ? I have a
    documents
    table in my database:
    Copy code
    pgsql
    create table documents (
      id uuid default uuid_generate_v4() not null,
      title text not null,
      content text not null,
      -- ... other columns
    )
    I would like to get all the document titles in sync with my app state. So I only need to listen for changes on the
    title
    column, but not on the
    content
    column (it would be a waste to download the payload each time the
    content
    changes while I only need the
    title
    ?). So is it possible to listen for changes on a specific column? Or is there an alternative solution?
    g
    • 2
    • 1
  • What is the problem with self hosting?
    m

    Milou

    08/16/2022, 1:44 PM
    Because this is more of a discussion type question, I wanted to ask in the #843999948717555735 channel, but since thats gone, I'll ask here: What is the problem with self-hosting apart from missing authentication in the backend? Sure it's not great, and for some people that may be the killer feature missing, but for smaller Apps this all seems fine? (I'm asking because a recent european ruling on privacy made it impossible to use US cloud hosted services for public contract work)
    a
    • 2
    • 1
  • Foreign Key Array Columns
    l

    luke90275

    08/16/2022, 3:38 PM
    Hi, I'm having trouble understanding or finding resources on columns of foreign key arrays. Say I have a post that people can comment on. So, I would think that I could add an array of the primary id's of comments to a post. However, this would run 2 dabatase functions (one to create each comment and the other to add the comments primary id to the post). The alternative would be to add the primary id of the post to the comment (and get rid of the comment array in the post). However, this method would require 2 database functions to obtain all of the data from a post (one to get the post itself and one to query all comments with the appropriate post id (as opposed to the first method which would require only one query with joins)). Is there a better way, where it only requires 1 database function to create the comment and 1 database function to get the post with its comments? If not, which method (1st or 2nd) is more popular or would you recommend? Thanks in advance!
    g
    • 2
    • 2
  • Are there any storage bucket, folder naming conventions to know of?
    l

    Lukas V

    08/16/2022, 3:41 PM
    Hello, I want to store recipe pictures in storage, I am planning to make all recipe pictures public, however only allow deletions for the owners of the document. I was thinking creating
    user-content
    bucket and create a folder named after
    uuid
    of each user, I guess its the easiest way to tell who owns that folder, but would this add any complexity in the future if for example I wanted to generate new thumbnail version for each recipe image, would it make hard to find? instead just have 1 bucket
    foods
    and store everything there. What is the best way to organise this sort of images?
  • database connection limit
    m

    Mount Everest

    08/16/2022, 4:04 PM
    hey! so, im curious about the connection limit, like how much connection you can connect simultaneously, is there any way to check it?
  • Can't generate types from CLI
    c

    cdedreuille

    08/16/2022, 4:29 PM
    I tried the new CLI to generate types from a URL wit this command
    supabase gen types typescript --db-url https://xxx.supabase.co
    and this is the error I received:
    Copy code
    supabase gen types typescript --db-url https://xxx.supabase.co
    Error: node:internal/process/promises:279
                triggerUncaughtException(err, true /* fromPromise */);
                ^
    
    [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
      code: 'ERR_UNHANDLED_REJECTION'
    }
    Did I do something wrong? FYI, Docker is running and if I run supabase start it works locally as expected. Thanks
    p
    w
    e
    • 4
    • 33
  • Nextjs and realtime subscriptions
    k

    Kariak

    08/16/2022, 4:57 PM
    Hi 👋 still getting my bearings on react with supabase and struggling with setting up a db subscription on a table of games and having it update games when theres a change in the db. When I try to write functions to create the subscription etc. outside of useEffect I get linter warnings but when I do all of it inside useEffect I also get warnings that I need to include variables for re rendering but I don't want the connection to be reset. How can I get the subscription to be created on load. Keep the component from re rendering so the subscription doesn't go away but also update the state so my list components re render with the new data? note: nfl_games is initially from my server side call where I hit the supabase db and then pass it as a prop to the component. Here's my useEffect code snippet.
    Copy code
    useEffect(() => {
      setGamesList(nfl_games)
      const nflGamesSubscription = supabase
        .from('nfl_games')
        .on('*', (payload) => {
        handleGameUpdate(payload)
         })
         .subscribe()
        
      const handleGameUpdate = (gameUpdate) => {
        const changedGameKey = gameUpdate.old.GameKey
        const updatedGames = games.map(game => game.GameKey === changedGameKey ? gameUpdate.new : game)
        setGames(updatedGames)
        }
        return () => {
          supabase.removeSubscription(nflGamesSubscription)
        }
    }, [nfl_games, gamesList])
    g
    • 2
    • 3
  • supabase_rest_backend crashing every 15-20 seconds
    l

    LukeB

    08/16/2022, 5:00 PM
    After upgrading the supabase cli to v1, supabase_rest_backend is crashing every 15-20 seconds. Is anyone else experiencing this and/or fixed it?
    g
    c
    • 3
    • 5
  • Supabase Storage design help
    o

    omar

    08/16/2022, 5:26 PM
    I'd like to have files listed on the client from supabase storage so a user should have file storage (bucket or folder associated with their id or email. What's the best way to do that? Is there a way to create user associated folders in an existing bucket or do I create a separate bucket for each user?
    g
    • 2
    • 5
  • Unable to create storage bucket
    b

    Blay3r

    08/16/2022, 6:16 PM
    Hi, I want to create storage bucket but I'm getting this error "Tenant config for ripudyqmboufsjyccnxr not found"
    g
    • 2
    • 2
  • Policy to check user belongs to team
    g

    guifromrio

    08/16/2022, 6:46 PM
    Hi, there! Noob question: I want to check if this user belongs to the team which owns the site so the user can select/update etc. I have a Sites table with a "team" property (foreign key to Team id), Teams table, and finally a Members table, with "user_id" and "team". I can't seem to find any good example on creating a policy which looks up "Members" to check whether the currently logged in user belongs to the team which is referenced in the "team" property. My feeble attempt does not work:
    Copy code
    (EXISTS ( SELECT m.user_id,
        m.team
       FROM "Members" m
      WHERE ((m.team = team) AND (m.user_id = uid()))))
    Do I have to INNER JOIN?
    g
    l
    • 3
    • 65
  • Listen to single row changes with v2-client
    w

    wiesson

    08/16/2022, 7:01 PM
    Previously, I could do sth like this:
    Copy code
    export function subscribeToInvoiceById(id: string) {
      return supabaseClient
        .from(`invoices_invoice:id=eq.${id}`)
        .on("UPDATE", async (payload) => {
          if (payload.new) {
          ...
    My use case is that I'd like to listen to single row changes (e.g. by id) - not sure if I missed sth in the docs, but I can't find how I do it with v2-client
    g
    • 2
    • 5
  • function uuid_generate_v4() does not exist
    c

    ChrisB

    08/16/2022, 7:14 PM
    I was trying to run some of the setup scripts from the Remix K-pop stack and they failed due to above. On checking extension UUID-OSSP is installed and enabled. Running
    create extension "uuid-ossp" with schema extensions;
    also confirms this but the script
    select uuid_generate_v4();
    fails with above error.
    g
    d
    +3
    • 6
    • 27
  • How to check if a column contains a given string (exactly)
    m

    MaxTechnics

    08/16/2022, 8:26 PM
    I have a column with id's. I want to check if a given id is already in that column, how do i do that? My current code is
    Copy code
    js
    const { data, error } = await supabase.from('my-table').select('id-column').contains('id-column', user_data.id);
    This however, does not work. Thanks!
    p
    • 2
    • 4
  • Realtime not working with RLS
    p

    Pierre_

    08/16/2022, 9:01 PM
    Hello! I am trying to listen for changes in realtime on a table called
    folders
    , on which I have a few simple policies:
    Copy code
    pgsql
    create policy "Users can create folders" on folders
      for insert with check (auth.uid() = user_id);
    
    create policy "Users can view their own folders" on folders
      for select using (auth.uid() = user_id);
    
    create policy "Users can update their own folders" on folders
      for update using (auth.uid() = user_id);
    
    create policy "Users can delete their own folders" on folders
      for delete using (auth.uid() = user_id);
    So I created a subscription like so:
    Copy code
    ts
    const subscription = client.from("folders").on("*", (payload) => {
      console.log(payload)
    }).subscribe()
    The websocket connection is created successfully, however when I
    INSERT
    or
    UPDATE
    some folders, it wasn't receiving any message (except a few times, randomly, I didn't figure out why). Yet, it was receiving the
    DELETE
    messages. So I disabled RLS on
    folders
    table, and now it was working perfectly. **Project ID**: hgqnfohuvgxsdcoymawt I really don't have any idea on how to fix this, so I would really appreciate your help!
    g
    p
    • 3
    • 90
  • security
    m

    meir

    08/16/2022, 9:47 PM
    hi guys the product seems awesome 👍 just wanted to ask a nube question: isn't the fact that the VITE_SUPABASE_KEY can be found in the client site - a security issue ? shouldn't it be confidential ?
    p
    • 2
    • 5
  • replication
    m

    meir

    08/16/2022, 9:54 PM
    hi 1. i am trying to understand if its possible to configure a second instance of postgres db ? 2. when creating a new publication, does it reduce the load from the original db?
  • Supabase type generation not working
    h

    harsh singh

    08/17/2022, 12:23 AM
    I've ran Supabase locally on docker with
    supabase start
    and I tried to run
    supabase gen types typescript --local > typings/db.types.ts
    but I get an empty TypeScript file with zero errors.
    z
    • 2
    • 2
  • How to use Prisma with Supabase Auth?
    t

    trilltrill

    08/17/2022, 1:49 AM
    Hi, does anyone know how to set up Prisma with Supabase Auth? I'm using Supabase Auth and when I try to set up Prisma, it gives the error "The schema of the introspected database was inconsistent: Illegal cross schema reference from public.profiles to auth.users" 😦 Would anyone please help me?
    o
    n
    +2
    • 5
    • 102
  • Is there any way to add values to an text array column with UPDATE?
    l

    lyqht

    08/17/2022, 2:15 AM
    Hello there, I have found this issue on this question https://github.com/supabase/supabase/discussions/1570 in 2021. Wondering now with supabase-v2, is there a way to add values to an array column directly? Ideally I don't wanna work with rpc.
    g
    • 2
    • 3
  • How do I enable Third Party Providers with self-hosted Supabase stack?
    z

    Zeevo

    08/17/2022, 2:18 AM
    I only ever get
    {"code":400,"msg":"Unsupported provider: Provider is not enabled"}
    when I use
    supabase/ui
    to log in to a Third Party Provider. When I open Studio I don't see any
    Configuration
    options on the Default project. Does anyone know how to enable third party providers on a locally hosted stack?
    • 1
    • 2
  • Is there a way to change where Kong redirects?
    z

    Zeevo

    08/17/2022, 3:39 AM
    After the OAuth handshake, Kong always sends the access token to
    http://localhost:3000
    . Is there an easy environment variable I can set to send to
    http://localhost:3000/alternative-path
    ?
    a
    • 2
    • 2
  • Using a different Supabase project for development
    r

    rison

    08/17/2022, 4:42 AM
    I read that the local development doesn't support storage and functions apis yet. How do I setup storage locally. Also, if I don't want to setup local, and just a different supabase project for development, is that possible with the new workflow? I was thinking of just using
    db commit
    to pull changes from the dev project, and use the new CI/CD workflow to update the production project. Is that a good way to go about it?
  • 42P01 relation public.profiles does not exist
    f

    felsey

    08/17/2022, 6:31 AM
    I'm getting an error saying that the relation does not exist when it does. It happens when I invoke the function. Here's the code I'm using:
    Copy code
    const test = async (req: any) => {
      try {
        // Set the Auth context of the user that called the function.
        // This way your row-level-security (RLS) policies are applied.
        supabaseClient.auth.setAuth(
          req.headers.get("Authorization")!.replace("Bearer ", "")
        );
    
        const { data, error } = await supabaseClient.from("profiles").select("*");
        console.log({ data, error });
    
        return new Response(JSON.stringify({ data, error }), {
          headers: { "Content-Type": "application/json" },
          status: 200,
        });
      } catch (error) {
        return new Response(JSON.stringify({ error: error.message }), {
          headers: { "Content-Type": "application/json" },
          status: 400,
        });
      }
    };
    
    serve(test);
    
    console.log("hello world");
    g
    • 2
    • 4
12345...230Latest