https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Sometimes it gets CHANNEL_ERROR status when subscribing
    w

    wasinwatt

    12/30/2022, 5:53 PM
    This happens like 60% of the time. 40% of the time the status is SUBSCRIBED and I think it only started behaving this way recently.
    g
    • 2
    • 20
  • Can't extract email on database trigger function
    l

    Lukas V

    12/30/2022, 6:18 PM
    Hey I have a function that triggers when new user gets added:
    Copy code
    begin
      insert into public.users (id, full_name, avatar_url, email)
      values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url', new.raw_user_meta_data->>'email');
      return new;
    end;
    Everything works except email which is not added to the users table, what is the reason for it, is there a different way I should be extracting email?
    g
    l
    • 3
    • 15
  • Has anybody connected their db to HubSpot?
    e

    Edan

    12/30/2022, 6:57 PM
    Trying to figure out what would be the best approach to achieve a full sync. This would be ideal to view users in a more friendly way, see their last log ins, email them marketing material and more.
  • Complex insert into multiple tables
    b

    BadBadJellyBean

    12/30/2022, 7:06 PM
    I want to insert data into multiple tables at once and I was wondering what the most canonical way this is. I was wondering if it is supposed to be a client side problem or if this should be done through edge functions or PG functions. My intuition would be to put some kind of abstraction in between but I am unsure if that is the "best" way.
    g
    • 2
    • 1
  • Apple OAuth - OAuth state is invalid signature is invalid
    m

    Michael Maust

    12/30/2022, 7:29 PM
    I'm working on getting Apple OAuth working on my local dev environment. I've gotten everything working up to the point where apple redirects the user back to the app. I keep getting the following error message: {"code":400,"msg":"OAuth state is invalid: signature is invalid"} Any ideas what I am missing? My config.toml for the apple sign in is as such:
  • Typescript types for jsonb field?
    l

    leviwhalen

    12/30/2022, 8:21 PM
    Hello friends! Last night I tried generating typescript types for my project, and it worked great. However I'm hitting an issue now where a
    jsonb
    field is typed as
    Json
    -- but I would like to define it using another type in my application. Is there a way to pass that type in a similar way to injecting the
    Database
    type during client initialization? Thanks!
    l
    s
    +2
    • 5
    • 10
  • Row Level Security policies based on other tables?
    k

    kevinwasie

    12/30/2022, 8:40 PM
    We are looking for another solution for our DB/API provider for an existing app. Specifically, we have hit our limit with their security policy functions. I've trialed Supabase system and have 2 main questions regarding the security policies: 1) Can row level security reference other objects outside of the table that the policy is being written on? For instance, we have the following: Users = {id, name} Projects = {id, name, commission, due_date) Users_To_Projects = {id, user_id, project_id, role} Teams = {id, name} Users_To_Teams = {id, user_id, team_id, role) We need to write a Row Level Security policy to only allow: 1) users with role 'admin' on Users_To_teams, must only be allowed to create projects for their team 2) users can only view projects that they are part of in Users_To_Projects 3) users with role Users_To_Projects.role = Project_Manager can only Update or Delete projects that they have access to. // ie, User_To_Projects.role = Contractor cannot Update or Delete 2) We would like to extend this further to column level security for objects. For instance, only users with Users_To_Projects.role = Project_Manager can view Projects.commission. All other roles cannot view this column. Is this possible with Supabase policies? Thank you, Kevin
    g
    • 2
    • 1
  • Using generated types
    i

    intheclouddan

    12/30/2022, 8:43 PM
    I'm trying to use generated types with my client, but for some reason it's still showing
    any
    for the Schema? I'm not sure what I'm doing wrong with it
    s
    • 2
    • 1
  • I think I'm having a caching issue? SvelteKit-Supabase
    d

    DDupasquier

    12/30/2022, 9:05 PM
    Sorry for the weird title. So here's the deal. I have a supabase query which replaces the old file if you try to upload another one with the same name. This works swimmingly and reflects my changes in the db. But when I refresh the page in my Svelte app, the assets don't update. I'm relatively new to Svelte so I'm thinking that there may be something fundamental that I'm missing. Does Svelte have some kind of built in caching system that I need to override? Here is the entire code block which manages the GET of the storage assets:
    Copy code
    js
    const getMyStories = async () => {
            if (profileId) {
                const { data, error } = await supabase
                    .from('stories')
                    .select(
                        'id, title, author, updatedAt, profileId (id, username, avatarUrl), pages: pages (id, background, screenshot)'
                    )
                    .eq('profileId', profileId)
                    .order('updatedAt', { ascending: false });
                if (error) {
                    throw new Error(error.message);
                }
    
                stories = data;
            }
        };
    
        onMount(() => {
            supabase.auth.getSession().then(({ data }) => {
                session = data.session;
            });
    
            supabase.auth.onAuthStateChange((_event, _session) => {
                session = _session;
            });
        });
    
        afterUpdate(() => {
            getMyStories();
        });
    So basically I'm getting my session onMount. Once the component is mounted I go ahead and get my thumbnails based on information I received from the session. Assets in storage reflect my changes. Client does not. Is this a svelte thing? Thanks in advance for any advice!
    s
    • 2
    • 28
  • Database Function Docs
    t

    typeleven

    12/30/2022, 9:48 PM
    I have picked up that you can use auth.uid() in a function and you can use the variable new to get values of a created record. Is this information somewhere in the docs? I have only found these by watching youtube videos from supabase but I feel there is more for me to know, for example is there a variable like new but for a record that is being updated? are there other things I can do with the auth object? I just want to know know where I can go to read but the only thing about functions in the docs that I see is how to invoke them but not how to write them. Is there a repo of example functions I could read through maybe?
    g
    s
    • 3
    • 4
  • Getting stale data from Supabase storage.
    d

    DDupasquier

    12/30/2022, 10:06 PM
    So here's the deal. I have a supabase query which replaces the old file if you try to upload another one with the same name. This works swimmingly and reflects my changes in the db. But when I refresh the page in my Svelte app, the assets don't update. I'm relatively new to Svelte so I'm thinking that there may be something fundamental that I'm missing. Does Svelte have some kind of built in caching system that I need to override? Here is the entire code block which manages the GET of the storage assets:
    Copy code
    js
    const getMyStories = async () => {
            if (profileId) {
                const { data, error } = await supabase
                    .from('stories')
                    .select(
                        'id, title, author, updatedAt, profileId (id, username, avatarUrl), pages: pages (id, background, screenshot)'
                    )
                    .eq('profileId', profileId)
                    .order('updatedAt', { ascending: false });
                if (error) {
                    throw new Error(error.message);
                }
    
                stories = data;
            }
        };
    
        onMount(() => {
            supabase.auth.getSession().then(({ data }) => {
                session = data.session;
            });
    
            supabase.auth.onAuthStateChange((_event, _session) => {
                session = _session;
            });
        });
    
        afterUpdate(() => {
            getMyStories();
        });
    Copy code
    js
    export const getPageThumbnail = async () => {
            if (story?.pages[0].screenshot) {
                const { data: url } = supabase.storage
                    .from('page-screenshots')
                    .getPublicUrl(story.pages[0].screenshot);
                return url;
            }
        };
    
        let background: { publicUrl: string } | undefined;
        $: url = background?.publicUrl;
    
        afterUpdate(() => {
            setTimeout(async () => {
                background = await getPageThumbnail();
            }, 10);
        });
    So basically I'm getting my session onMount. Once the component is mounted I go ahead and get my thumbnails based on information I received from the session. Assets in storage reflect my changes. Client does not. Is this a svelte thing? Thanks in advance for any advice!
  • New row violates row-level security policy
    a

    AmusedGrape

    12/30/2022, 10:14 PM
    I'm getting this error:
    new row violates row-level security policy for table "listItems"
    when using
    .select(*)
    after a
    .insert()
    . Inserting works fine, so selecting is the issue. My select RLS code:
    can_view_list(( SELECT profiles.id FROM profiles WHERE (profiles."user" = uid())), list)
    Function code:
    Copy code
    sql
    create or replace function can_view_list(user_id uuid, list_id uuid)
    returns bool
    language plpgsql
    as
    $$
    BEGIN
      IF (SELECT "sharingStatus" FROM lists WHERE id = list_id) = 'invite' THEN
        return exists (SELECT * FROM "listUsers" WHERE "user" = user_id);
      ELSE
        return true;
      END IF;
    END $$;
    I'm not entirely sure what the issue is; Running
    select can_view_list('...', '...')
    (ids omitted), it works fine. Any ideas?
    g
    • 2
    • 2
  • Issuer URL
    m

    Martacus

    12/30/2022, 10:53 PM
    I am using AWS's API gateway and would like JWT authorization for mu users. It's asking for the Issuer URL but cannot find in the docs where this url would be located. I also checked the access_token JWT but don't see issuer under there.
    g
    • 2
    • 1
  • 👾 Database memory usage is always high
    h

    harryc

    12/30/2022, 11:02 PM
    Hi, my supabase database (free tier) memory usage is always hovering around 90%, never seem to decrease. As database requests fluctuate throughout the day, isn't the memory usage supposed to go up and down as well? (I might be completely off here. I'm not used to looking at database metrics) Also, are compute add-ons just not available on free tier? Thanks!
    g
    • 2
    • 4
  • Max connections for free tier
    d

    Domain Controller

    12/30/2022, 11:17 PM
    Hey, I was wondering if anyone has an estimate of how many connections the free tier can handle before performance issue arises? My assumption is that the database has around 64-128MB of RAM but not sure if that's correct.
  • Receiving incorrect storage assets
    d

    DDupasquier

    12/30/2022, 11:19 PM
    I have a div which renders multiple images based one the publicUrl. In this images provided, sometimes when navigating through the pages the assets render out of order. This is the code which is getting the data for each individual page: +page.ts (/[page_id])
    Copy code
    js
    import { supabase } from '$lib/supabase';
    
    export async function load({ params }: { params: { page_id: number } }) {
        const { data: page, error } = await supabase
            .from('pages')
            .select(
                'id, pageNumber, background, elements: elements (id, elementName, x, y, zIndex, size, type, color, text, pageId)'
            )
            .eq('id', params.page_id);
    
        if (error) {
            throw new Error(error.message);
        }
    
        return {
            page
        };
    }
    The page then consumes the data and passes it to a canvas element:
    Copy code
    js
    <script lang="ts">
        import Canvas from '$lib/components/canvas/Canvas.svelte';
    
        export let data: EditPageProps;
    </script>
    
    <Canvas info={data.page[0]} />
    The canvas element then takes that data as props and provides the element data to an ImgElement component:
    Copy code
    js
    <script lang="ts">
        import { supabase } from '$lib/supabase';
        import { onMount } from 'svelte';
        import { page } from '$app/stores';
        import { screenshotCanvas } from '$lib/utils';
        import ImgElement from '$lib/components/canvas/ImgElement.svelte';
        import { uploadThumbnail, saveBgColor } from '$lib/services/pageActions';
        import ColorPicker from '../ColorPicker.svelte';
    
        export let info: {
            id: number;
            pageNumber: number;
            background: string;
            elements: PageElement[];
        };
        
        $: background = '';
    
        const setColor = (color: string) => {
            background = color;
        };
    
        onMount(async () => {
            background = info.background;
    
            supabase
                .channel('public:elements')
                .on('postgres_changes', { event: 'INSERT', schema: 'public' }, (payload) => {
                    info.elements = [...info.elements, payload.new] as PageElement[];
                })
                .subscribe();
    
            supabase
                .channel('public:elements')
                .on('postgres_changes', { event: 'DELETE', schema: 'public' }, (payload) => {
                    info.elements = info.elements.filter((element) => element.id !== payload.old.id);
                })
                .subscribe();
        });
    
        const doScreenshot = async () => {
            const file = await screenshotCanvas('#canvas');
            file && uploadThumbnail(file, $page.params.page_id);
        };
    </script>
    
    {#if info.background}
        <div id="canvas" style="background: {background}">
            {#if info.elements}
                {#each info.elements as element}
                    <ImgElement {element} />
                {/each}
            {/if}
            <div class="page">
                Page {info.pageNumber}
            </div>
        </div>
    {/if}
    
    <div class="controls">
        <ColorPicker color={background} {setColor} />
        <button
            class="save"
            on:click={() => {
                doScreenshot();
                saveBgColor(info.id, background);
            }}
        >
            Save
        </button>
    </div>
    g
    s
    • 3
    • 23
  • sending custom auth emails - kill switch for internal emails
    l

    logemann

    12/31/2022, 12:06 AM
    its easy enough to create your own confirmation emails for various actions but how do i disable the internal email sending of the template string which we can configure in the UI. Of course i dont want to send one custom email and the one provided by supabase. Currently i am using a /dev/null custom email service so that the supabase generated email just goes to oblivion but i dont want to use a 3rd party service for something like this. Is there really no kill-switch for the internal email sending? thx.
    g
    • 2
    • 2
  • Local development not working
    d

    draco

    12/31/2022, 12:25 AM
    I might just be exceptionally stupid or tired, but absolutely nothing I have tried will get my local supabase functioning properly. I have gone through all the steps in the readme to get the cli, init a project, login with an access token and start, but I simply get a message saying "Started local Supabse". I can't navigate to the local dashboard and nothings else seems to work. What am I missing here? Please help, I am so lost.
    s
    • 2
    • 4
  • Verbose mutations...is there a better way?
    b

    Brian

    12/31/2022, 12:44 AM
    I'm using react-query to save data from the client using the js library. When dealing with relational tables (often) and using
    upsert
    , my code feels very verbose. After using
    useMutation
    and handling all of the
    onError
    and
    onSuccess
    responses for the first insert then doing it all again for the the relational insert, it's a lot. Then, add in some code to check if it's an update or new insert and things are getting pretty hard to read. Anyone have some production code examples where they're mutating multiple relational tables and feel their code is succinct?
    • 1
    • 1
  • supabase start doesn't work
    k

    Kai NABETA

    12/31/2022, 3:05 AM
    When I run
    supabase start
    , it does not start up and I get the following error Do you know of any solutions?
    Copy code
    Error: failed to connect to `host=localhost user=postgres database=postgres`: dial error (timeout: dial tcp 127.0.0.1:54322: i/o timeout)
    Try rerunning the command with --debug to troubleshoot the error.
    s
    a
    +2
    • 5
    • 13
  • Returning a helpful Error message from an Edge function?
    u

    49Ryann

    12/31/2022, 3:24 AM
    I'm following the code examples sending an error message back from an edge function but I always get this message back on my frontend?
    Copy code
    FunctionsHttpError: Edge Function returned a non-2xx status code
    Copy code
    {
      name: 'FunctionsHttpError',
      context: Response {
        type: 'cors',
        url: 'https://xoehwyftrgxzpwtgsesp.functions.supabase.co/verify-mobile',
        redirected: false,
        status: 400,
        ok: false,
        statusText: '',
        headers: Headers {},
        body: ReadableStream { locked: false },
        bodyUsed: false
      },
      stack: 'FunctionsHttpError: Edge Function returned a non-2xx status code\n' +
        '    at FunctionsClient.<anonymous> (http://localhost:4200/vendor.js:5579:17)\n' +
        '    at Generator.next (<anonymous>)\n' +
        '    at fulfilled (http://localhost:4200/vendor.js:5493:24)\n' +
        '    at _ZoneDelegate.invoke (http://localhost:4200/polyfills.js:10072:158)\n' +
        '    at Object.onInvoke (http://localhost:4200/vendor.js:114063:25)\n' +
        '    at _ZoneDelegate.invoke (http://localhost:4200/polyfills.js:10072:46)\n' +
        '    at Zone.run (http://localhost:4200/polyfills.js:9855:35)\n' +
        '    at http://localhost:4200/polyfills.js:10948:28\n' +
        '    at _ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:10099:171)\n' +
        '    at http://localhost:4200/vendor.js:113743:49',
      message: 'Edge Function returned a non-2xx status code'
    }
    Heres how it's sent back from the edge function:
    Copy code
    return new Response(JSON.stringify({ error: 'Mobile number is not valid.' }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 400 })
    any ideas? I can easily write an error on the frontend as it's a specific function I'm calling but I'd prefer getting feedback from the server.
    • 1
    • 1
  • Postgres and API types out of sync
    u

    56e5

    12/31/2022, 4:09 AM
    Hi, I updated my PKs from
    serial
    (i.e.
    int
    ) to
    uuid
    and now I get a type-related error back from the API because the ID I'm passing is not an integer: > 22P02: invalid input syntax for type integer: "40dfbd05-9126-4a36-81a8-211cf8f28d1c" I've checked the DB (both through a PG client and the Supabase admin UI) and the column type has been updated to UUID fine. Is there some way to flush the API schema? Maybe it's a Cloudflare caching thing? Thanks!
    g
    • 2
    • 6
  • I'm getting the error below
    m

    Mr_Incredible442

    12/31/2022, 8:08 AM
    Uncaught TypeError: Failed to resolve module specifier "@supabase/supabase-js". Relative references must start with either "/", "./", or "../".
    u
    s
    • 3
    • 10
  • Supabase-js reauthentication.
    i

    izurugi

    12/31/2022, 8:26 AM
    Hello I am wondering if is there a javascript method for this api? https://github.com/supabase/gotrue#get-reauthenticate
    g
    • 2
    • 1
  • How to stay logged in over longer periods of time?
    f

    Florian

    12/31/2022, 11:07 AM
    I notice that I'm getting logged out after 2 days or so. How can I stay logged in indefinitely without increasing the JWT expiration time?
    z
    g
    • 3
    • 12
  • Can I use supabase auth to authenticate with GAPI?
    e

    evro.eth 🇵🇷

    12/31/2022, 3:11 PM
    I'm writing a nextjs api and would love to use the supabase auth to authenticate w/ GAPI. Any docs? I assume I'd need to grab the token and push to auth headers? Any help would be appreciated.
    s
    • 2
    • 3
  • Packaging self-hosted Supabase with an application?
    z

    zilchg00d

    12/31/2022, 3:40 PM
    I'm working on a desktop application built with electron and I'm looking for a way to bundle Supabase into the build so that it will be preconfigured and working on install. Is that something that is doable? Thanks,
  • Supabase Locally
    r

    Razil

    12/31/2022, 5:24 PM
    Hello, I'm using Supabase locally for development and I have a question; I noticed that every time I run
    supabase start
    it will redownload the docker images (if you previously died a
    supabase stop
    ) it needs, can this behavior be changed? Not sure why it's deleting the once-downloaded images.
    s
    • 2
    • 3
  • How to create a column_updated_at field in the Supabase DB
    c

    C o m f i i

    12/31/2022, 5:36 PM
    I'm trying to create a table with two columns:
    data
    , and a
    data_updated_at
    timestamp column which updates only when
    data
    is updated
    g
    • 2
    • 16
  • Realtime for tables with composite primary key and composite fkeys
    v

    vikramark

    12/31/2022, 5:53 PM
    The realtime flutter subscription doesn’t work for tables that have multiple composite foreign key constraints and composite primary key. It works for simpler tables with single primary key. All the websocket logs on Supabse dashboard show status 200. How can I monitor the websocket from the Supabase dashboard?
    g
    • 2
    • 6
1...838485...230Latest