https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Full refresh required to receive updates from realtime for table with RLS - (auth.uid() = user_id)
    u

    Ursa

    03/17/2023, 4:14 PM
    Hey all, I'm running into an issue where I'm not receiving realtime updates from a table where a user should only see their own posts. This only happens when a user first logs in before they refresh the page. I'm using SvelteKit with progressive enhancement to avoid refreshing the page when a user logs in, creates a post, etc. If I bypass RLS on the table by changing (auth.uid() = user_id) to just "true" I immediately receive updates when I first log in from the table. Is there something I should be doing on login or elsewhere to receive realtime updates protected by RLS without refreshing the page?
    g
    • 2
    • 4
  • .order() option foreignTable
    q

    QueueBot

    03/17/2023, 4:23 PM
    Documentation says “Set this to order a foreign table by foreign columns.” Why is this a required value? What should I set it to if I’m not using foreign data wrappers?
    g
    • 2
    • 7
  • Why is supabase.auth.getUser() null in onAuthStateChange?
    g

    gtims123

    03/17/2023, 4:31 PM
    After I sign a user in and the SIGNED_IN event triggers in onAuthStateChange, user is null when getUser() is called inside of onAuthStateChange. This is a problem because I have RLS set up on my profiles table and I can't fetch the user's profile in onAuthStateChange.
    r
    • 2
    • 45
  • How to make one of the composite primary key nullabes?
    u

    ?????

    03/17/2023, 5:03 PM
    For what i known, in sql i can do it, but supabase thrown a error when i try.
    g
    • 2
    • 2
  • Supabase, Clerk, and Next
    a

    asyncme

    03/17/2023, 6:26 PM
    Has anyone worked with Clerk and Next in the same project? I am wondering if it's possible to render the authentication/syncing on the server instead of the frontend?
    h
    • 2
    • 1
  • Ignore SIGN_IN event when it's a tab switch
    r

    Rake

    03/17/2023, 6:49 PM
    Switching in and out of tabs causes the SIGN_IN event. I have a method I'd like to be called when this happens but I don't want it to happen every time someone switches tab. For context, I'm using the latest verson of Next and the auth helpers.
    m
    s
    • 3
    • 6
  • pgsodium is not generating views for tables able enabling the SECURITY LABEL
    t

    Terminal

    03/17/2023, 7:09 PM
    I've created a table with a field that I need encrypted. However when enabling the security for the field. The views table isn't being generated
    Copy code
    SECURITY LABEL FOR pgsodium
        ON COLUMN tableA.token
      IS 'ENCRYPT WITH KEY COLUMN key_id;
    • 1
    • 1
  • Storage CORS policy?
    p

    PauHana

    03/17/2023, 7:19 PM
    In an aws S3 bucket you can set a CORS policy, is there a way to do this with Storage, or do I need to proxy images on to my domain to be able to put them in a canvas-generated screen shot?
  • Reset Passord
    s

    Stuart81

    03/17/2023, 8:10 PM
    Hey everyone, i have been struggling to understand how a user can reset a a passord
    c
    • 2
    • 4
  • Update problems
    k

    Kypac

    03/17/2023, 8:46 PM
    I'm trying to update a table but is not working.
    g
    • 2
    • 5
  • Svelte/Vite user management -supabaseUrl is required?
    q

    Quazar

    03/17/2023, 8:56 PM
    Maybe I missed something following https://supabase.com/docs/guides/getting-started/tutorials/with-svelte I took a clue from the GitHub sources and created
    .env.local
    in the project root, with my URL and ANON_KEY It fails to run with
    Uncaught Error: supabaseUrl is required.
    s
    • 2
    • 6
  • Combine multiple unrelated .from().select() into 1
    n

    nbert

    03/17/2023, 8:58 PM
    Using supabase-js. Is it possible to combine multiple queries into a single one and return (in this case) 3 separate array's with objects? Having 3 separate
    supabase.from().select()
    seems very inefficient, so combining them (and making 1 request) sounds more efficient... But is it possible, and if so, how? Here's the code I'm currently running on the server before page load:
    Copy code
    ts
    export async function load() {
        const { data: materials } = await supabase.from('materials').select('id, name').order('id', { ascending: true });
        const { data: categories } = await supabase.from('categories').select('id, name').order('id', { ascending: true });
        const { data: tools } = await supabase.from('tools').select('id, category, name').order('id', { ascending: true });
    
        return {
            materials: materials ?? [],
            categories: categories ?? [],
            tools: tools ?? []
        };
    }
    g
    y
    • 3
    • 4
  • Adding username help
    s

    Sniped137

    03/17/2023, 9:16 PM
    anyone got a solution?
    • 1
    • 1
  • How to do a many to many query with the JavaScript SDK? Getting all posts from followed users
    v

    Vik

    03/17/2023, 10:19 PM
    Hey there, I need some assistance in setting up a query to get all the posts from users that the logged in user is following. Posts table: asset_url: string | null; content: string; created_at: string; post_id: string; user_id: string; Relationships: approved: boolean | null; created_at: string; follow_id: string; followee_id: string; user_id: string; I've already setup a RLS policy on the Posts table so you can only get posts if the account is not private or you have an approved relationship. This is how I currently query my posts on the frontend to get all the posts, but need to add a filter to only people I follow:
    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[];
    };
    • 1
    • 1
  • Custom Discord Authorization Link Not being used
    m

    michaelshimeles

    03/17/2023, 10:35 PM
    I'm using discord auth via supabase on my website, I'd like to know what servers users who have authenticated and joined. I've changed the default authorization link on the discord dev dashboard to update permissions but for some reason it's not working. Is there anyway else I can change the authorization link?
    s
    • 2
    • 1
  • Are triggers a viable option to updating a tables "total_likes" and "total_replies"
    v

    Vik

    03/18/2023, 3:52 AM
    I'm still a little new to Postgres and let's say you're running a Twitter database. Would someone like storing the count of likes and replies on the posts table be a good option? I'm thinking about running a trigger for insert and delete to update these counts anytime that happens. Not sure about the performance though more importantly.
    g
    • 2
    • 4
  • Make only certain columns public
    a

    anan7

    03/18/2023, 10:13 AM
    Hi I have a read online policy like (auth.email() = 'test@email.ae'::text). However I want to give access to public to read only certain columns that are not sensitive. Like for example, in this table, i have user name, phone number etc. I don't want to expose these but instead only expose booking id,date, time which are the other columns on this table.
    s
    • 2
    • 2
  • Error creating tables in Supabase with Node.js - MODULE_NOT_FOUND"
    i

    itsandyd

    03/18/2023, 10:17 AM
    Hi everyone, I'm trying to set up my Supabase tables using the setupSupabase.js script provided in the Supabase documentation, but I keep getting the error "No tables were created" when I run npm run setup-supabase. I've double-checked my Supabase URL and key and they seem to be correct. I'm wondering if anyone has experienced this issue before or has any advice on how to troubleshoot it? Thanks in advance for your help!
    s
    • 2
    • 2
  • signInWithPassword doesn't create a session?
    l

    LAH

    03/18/2023, 10:36 AM
    I'm encountering an issue where the supabase.auth.signInWithPassword function is not creating a session, whereas supabase.auth.signInWithOAuth does. Specifically, after calling the login function, the response indicates "success" and includes all relevant user data. However, when attempting to access this data from another page using the useUser() hook, it returns null. This issue is not present when using supabase.auth.signInWithOAuth. I'm using Next.js
  • How to pass user metadata on signUp() with the supabase-swift package?
    d

    Dyrsin

    03/18/2023, 11:01 AM
    Hello, I have asked this question on the subreddit also: https://www.reddit.com/r/Supabase/comments/11u8brh/how_to_pass_user_metadata_on_signup_with_the/ I am building an app with Xcode in Swift (& SwiftUI), using the supabase-swift package. I am trying to pass user metadata along with an email and password in a
    signUp()
    auth request:
    client.auth.signUp(email: user.email, password: user.password, data: user.profile)
    , where
    user.profile
    is a struct, that can be converted with
    JSONEncode()
    . The data parameter seems accessible, but the type is of
    [String: AnyJSON]
    , which after much tribulation has eluded my best search efforts so far. Has any one had this issue with this type? How can I pass user metadata in Swift, from a Data objet and/or JSON String? Thank you for reading & help. :)
    g
    • 2
    • 3
  • insert stopped working
    c

    chrtravels

    03/18/2023, 11:26 AM
    Hey all, For some reason my addPost function stopped working. I haven't changed anything on this component recently.
    Copy code
    export async function addPost (newPost)  {
      try {
        const { error } = await supabase
        .from('posts')
        .insert(newPost)
      } catch (err) {
        console.log(err);
        throw new Error('Error posting topic')
      }
    }
    Then, from the handleSubmit , called from the form button:
    Copy code
    function handleSubmit(e) {
    
        const newPost = {
            title: title,
            content: content,
            tags: tags,
            user_id: user.id
          }
    
          addPost(newPost);
      }
    I was getting "supabase" for the api functions, from '@/lib/supabase-js' and that was working. It actually still is on my other functions...getPosts, etc... However I also tried '@supabase/supabase-js' but neither work for this function. I am also not getting any errors. On the database side, the refresh spins but nothing is added. Any thoughts are appreciated.
    s
    o
    • 3
    • 7
  • Getting lots of "canceling statement due to statement timeout" errors
    a

    alitnk

    03/18/2023, 11:51 AM
    Our logs are filled with
    canceling statement due to statement timeout
    errors. We have staging and production instances and this happens only on production. any idea?
    g
    r
    • 3
    • 13
  • Why wont my function serve or deploy?
    d

    Dan Rumney

    03/18/2023, 1:24 PM
    I've opened a Github issue (https://github.com/supabase/cli/issues/939) and posted on Reddit (https://www.reddit.com/r/Supabase/comments/11uo4yk/opaque_errors_trying_to_serve_and_deploy_edge/). If posting here is considered spamming, rather than cross-posting, please let me know. I'm getting started with Supabase edge functions and have run into something of a wall. I have the following directory structure:
    Copy code
    my-app/
        ├─ supabase/
        │  ├─ functions/
        │  │  ├─ xyz/
        │  │  │  ├─ index.ts
    When I try to serve this function with
    supabase functions serve
    , I get
    Serving supabase/functions
    , but then nothing else... no mention of the file watcher or of function
    xyz
    . In addition, when I try to
    POST
    to this function, the terminal that is "serving" my functions says
    service does not exist
    In addition, when I attempt to deploy the function, I get the following with the regular bundler:
    Copy code
    Error: Error bundling function: exit status 1
    file:///src/import_map.json
    file:///src/index.ts
    error: Uncaught (in promise) Error: NotFound: No such file or directory (os error 2)
          const ret = new Error(getStringFromWasm0(arg0, arg1));
                      ^
        at __wbg_new_8d2af00bc1e329ee  
    <stack omitted due to character limit>
    The legacy bundler gives:
    Copy code
    Bundling xyz
    Error: Error bundling function: exit status 1
    error: Module not found "file:///Users/dancrumb/Projects/my-app/xyz/index.ts".
    I'm happy to try to debug further, but I'm kind of at a loss since the error messages for standard bundling are pretty opaque and I can't see why the legacy bundler would be looking in the wrong place.
    m
    • 2
    • 12
  • Is there any function that should set for how long the row should be in db?
    l

    Luc

    03/18/2023, 1:26 PM
    Is there any function that should set for how long the row should be in db?
    g
    • 2
    • 1
  • Diffing databases throws error
    m

    maxim

    03/18/2023, 1:49 PM
    when i run
    supabase db diff
    i get the following:
    Copy code
    ❯ supabase db diff
    
    
    Connecting to local database...
    Creating shadow database...
    Applying migration 20230227064514_create_projects.sql...
    Applying migration 20230227070734_create_units.sql...
    Applying migration 20230301134939_create_delete_units_rpc_function.sql...
    Applying migration 20230302062449_create_select_configurations_query.sql...
    Applying migration 20230311193213_create_developers_health_overview_rpc_function.sql...
    Applying migration 20230311195842_create_update_or_insert_rpc_functions.sql...
    Applying migration 20230312091731_create_search_rpc_function.sql...
    Diffing schemas: auth,extensions,public,storage
    Error: error diffing schema:
    
    Try rerunning the command with --debug to troubleshoot the error.
    Any idea what this could be? attached a log file with lines that contain "error" when i run it with
    --debug
    (cause 2k character limit on post):
    • 1
    • 1
  • Realtime Subscription closes immediately after page load
    p

    peepoo

    03/18/2023, 2:30 PM
    Version: "@supabase/auth-helpers-nextjs": "^0.5.4", "@supabase/auth-helpers-react": "^0.3.1", "@supabase/auth-ui-react": "^0.2.8", code:
    Copy code
    import { useSupabaseClient } from "@supabase/auth-helpers-react";
    export default function Index(){
      const supabase = useSupabaseClient();
      useEffect(() => {
        supabase
            .channel("supabase_realtime")
            .on("postgres_changes",{ event: "*", schema: "public", table: "Product"},(payload) => {
              console.log(payload.new);
            })
        .subscribe((status) => {
              console.log(status);
            });
       }, [supabase]);
    }
    The status always print CLOSED twice after the initial load of the page (if I made changes to the file and save it, the subscription is then working perfectly), but another realtime subscription with different table is working (print SUBSCRIBED) with the same coding structure.
    j
    • 2
    • 4
  • No rows returned after function definition.
    m

    MATTI

    03/18/2023, 2:52 PM
    I don't know much of this sql stuff, just needed to make a simple function for an application, so this is probably a newbie mistake. I created a function that does as I need it to, and it works fine. But when I try to define it as a function, which from my understanding is needed if I want to call the function from JS, it works, but no rows are returned. I will show it in the images below
    g
    • 2
    • 2
  • Social Auth Return URL access_token parameter removed
    s

    SirK

    03/18/2023, 3:14 PM
    Stack: NextJS | JS (Not TypeScript) After logging in through Google, Supabase redirects to index "/" with #access_token=XXXXXXXXXXXX. However, very quickly it gets removed from the url, leaving just /#. I managed to get screenshots to demonstrate this. I'm not sure where this issue is happening, if it's a problem with Next, or with how I configured my Auth in Supabase. Also, my goal with getting this access_token is to store it in localStorage so that the session persists if the tab is left. Is this the correct approach, or is there a better way? Any help would be greatly appreciated, thanks!
    g
    h
    • 3
    • 11
  • How do I sign out every user? or delete their sessions?
    t

    Torwent

    03/18/2023, 5:11 PM
    I've changed some things in my project and I need to logout every user or delete their sessions so they are forced to re-login so my third party provider (discord) ask for new permissions. How can I do this? I've tried as a test to delete rows in auth.sessions but it wouldn't let me...
    g
    n
    • 3
    • 4
  • Failing to deploy edge function to production
    a

    a99111cc042b477e9f22eafe7

    03/18/2023, 5:40 PM
    I am following this tutorial https://supabase.com/docs/guides/functions/quickstart to deploy edge function but I am getting this when trying to deploy.
    Copy code
    bash
    λ  supabase-functions main ✗ supabase functions deploy hello-world
    Error: fork/exec /home/anon/.supabase/deno: no such file or directory
    Does anybody else have this problem as well ? I am running a bit older cli version. supabase --version 1.29.3 I followed previous steps without an issue. I took already made supabase project. Created new folder, supabase login supabase init supabase link supabase function new hello-world supabase deploy hello-world // and I get this Error: fork/exec /home/anon/.supabase/deno: no such file or directory OS: NixOS 23.05pre4583
    • 1
    • 2
1...171172173...230Latest