https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Why is the created_at column nullable by default?
    o

    omri

    09/05/2022, 9:54 AM
    When you create a new table using the web interface it comes with a nullable
    created_at
    column by default, why is it nullable even though it has a default value of
    now()
    ?
    n
    • 2
    • 1
  • Typescript error on deployment
    l

    lampaboy

    09/05/2022, 11:13 AM
    Been trying to get this tutorial to work:- https://supabase.com/docs/guides/with-nextjs Able to deploy on dev but not promote to production on Vercel, which I believe due to a TS error on this block of code:
    Copy code
    const { subscription } = supabase.auth.onAuthStateChange(
          (_event, session) => {
            setSession(session)
          }
        )
    with this error,
    Property 'subscription' does not exist on type '{ data: { subscription: Subscription; }; }'.",
    This can be found under
    Launch.js
    here https://supabase.com/docs/guides/with-nextjs#launch
    l
    • 2
    • 2
  • Typescript Database Typings with CLI on Cloud Database
    s

    SETY

    09/05/2022, 12:02 PM
    Is this possible? Every post I see here using the v2 CLI only shows it for the Docker image of it.
    s
    • 2
    • 6
  • Caching on the frontend.
    u

    49Ryann

    09/05/2022, 1:36 PM
    What options do we have for caching queries on the front end? I was previously using a Graphql Apollo server previously and have moved the project across to Supabase and super happy so far, But previously Angular Apollo had a brilliant caching system that worked really well & I'm curious what options we have using Supabase for this? It seems arrays of items are re-loading on every page change as opposed to any caching happening, any thoughts on this or experience? As a side question does anyone know if I could continue to use Angular Apollo with the graphql Supabase backend? Seems like I should be able too just point it to the exposed Supabase Graphql uri.
    p
    j
    j
    • 4
    • 6
  • Check for user SSRNextJs, send props either way
    s

    Shin Miyagi

    09/05/2022, 2:48 PM
    I have a page which shows content for logged-in users if the user is indeed logged in. If they are not logged in then that content doesn't show. So I would like to get the user (if they exist) in
    getServerSideProps
    . However I only seem to be able to load the page for logged in users or redirect if they are not logged in as per https://github.com/supabase/auth-helpers/blob/main/packages/nextjs/README.md (Server-side rendering (SSR) - withPageAuth). I did find this https://github.com/supabase/auth-helpers/issues/109 where someone suggests to use
    authRequired: false
    , but whilst that does load the page without the user being logged in, if the user is not logged in it does not pass through the props. I am passing through critical data in getServerSideProps so that's no good. I created this test page:
    Copy code
    ...
    export const getServerSideProps = withPageAuth({
        
        authRequired: false,
        
        async getServerSideProps(ctx) {
    
            const { user } = await getUser(ctx);
            const message = "Some message"
    
            if (user) {
                return {
                    props: {
                        message: "User authenticated"
                    }
                };
            }
            
            else {
                return {
                    props: {
                        message: "User not authenticated"
                    }
                };
            }
        }
    
    });
    If the user is logged in,
    message
    makes it through to props. If the user is not logged in
    message
    does not get through to props, all I get is a null user object. Is there a way for me to check for the user SSR, if the user exists do some stuff, and then pass the rest of the data I am processing SSR through props to the app?
    n
    • 2
    • 27
  • return numeric identity after insert?
    o

    Omni

    09/05/2022, 2:59 PM
    Hello, I am very beginner at Supabase, and I am trying to use numeric sequential id, rather then uuid. I cannot find how to get back newly created id (using Supabase API), once insert operation is done. solution: run select after insert, e.g.
    insert({...}).select().single();
    k
    g
    • 3
    • 5
  • Flatten nested join
    j

    Julien

    09/05/2022, 3:37 PM
    Copy code
    ts
                supabase
                .from('playground')
                .select(`
                    photos:playground_photos(
                        photo(*)
                    ),
                `).eq('id', playgroundId)
                .single()
    This request returns a data object with the following structure:
    Copy code
    ts
    {
      photos: [
        {
          photo: {...}
        },
        {
          photo: {...}
        }
      ]
    }
    Is this possible to flatten that like so:
    Copy code
    ts
    {
      photos: [
        {
          ...
        },
        {
          ...
        }
      ]
    }
    So that I don't get an extra photo property? Without doing a for loop but directly in the query string of the select?
    s
    • 2
    • 16
  • FetchError (intermediate value).fetch is not a function
    j

    Jinni

    09/05/2022, 4:22 PM
    Hi. Can anyone help me?
    Copy code
    supabase.from("characters").select().then((response) => {
        console.log(response)
    })
    g
    • 2
    • 1
  • Migrate from mongodb to supabase
    j

    JTmaveryk

    09/05/2022, 5:57 PM
    I was interested in migrating from mongodb to supabase but was confused on the best documention to base off of or use in this transition process. I’m currently running a fastify server hosted in javascript and node.js.
    h
    • 2
    • 1
  • What's the meaning of the RETRY_AFTER_TIMEOUT status for subscriptions?
    o

    owonwo

    09/05/2022, 5:58 PM
    I would like to know how to handle my subscriptions when the status is "RETRYING_AFTER_TIMEOUT".
    g
    • 2
    • 32
  • Template for user registration
    g

    gbb

    09/05/2022, 6:25 PM
    Hello, I want to add a full html file as a template for the email confirmation Thing is I don't know if I should include the html, head, body etc tags, In the head I have a lot of styles including media queries. Will this work?
    g
    • 2
    • 1
  • Creating an anonymous session
    k

    Kieran Gill

    09/05/2022, 6:36 PM
    I have an API endpoint that I'd like to secure. Newcomers to the site should be able to use this API 2/3 times. Then, they should be required to login before making more requests. Ideally, newcomers would get assigned an anonymous session via some sort of fingerprinting mechanism. Is there a way to do this sessioned-anon-user type of thing?
    g
    • 2
    • 1
  • cron job says no space left on device when there is almost 2GB left
    r

    Relisora

    09/05/2022, 7:30 PM
    When looking at my cron_job_detail table, I noticed some jobs are failing. The error is:
    ERROR:  could not write to file "base/pgsql_tmp/pgsql_tmp<hash>": No space left on device
    I have the pro subscription and my db usage is 6.2GB/8GB. How can I fix this?
    g
    s
    • 3
    • 5
  • What is the best library to use Supabase with (React-query, SWR, useEffect) ?
    d

    DevThoughts

    09/05/2022, 7:36 PM
    What is the best client side library for Supabase for fetching data?
    j
    g
    +2
    • 5
    • 15
  • How can I add a leading zero to all my post codes?
    w

    weilzuvielgewalt

    09/05/2022, 7:50 PM
    Hey guys, I have a table with over 1000 store locations. I have imported them via CSV. The stores are located in Germany, so they have 5 digit post codes. But some of these post codes begin with a 0, so 01234 for example. Unfortunately, the 0 was removed after the import... Now some post codes are like this: 1234, while they should be 01234. How can I select all post codes with only 4 digits and add a leading zero to it?
    g
    • 2
    • 4
  • Missing Publication when trying to enable Realtime
    a

    AmusedGrape

    09/05/2022, 10:56 PM
    I'm trying to update an existing table to enable realtime (it already had realtime enabled so i'm not sure why I had to do this again?), but I keep getting "Unable to update realtime for [tablename]: Missing publication". Am I missing something or is this a known bug at the moment? Thanks! I also see this on the replication database settings page
    g
    b
    • 3
    • 13
  • Does anyone have any examples of db triggers on update and insert
    n

    n10000k

    09/05/2022, 11:30 PM
    If a user is updated with the column
    disabled = true
    , then i want to insert that record into another table. thanks in advance
    g
    • 2
    • 1
  • The Same Origin Policy disallows reading the remote resource
    j

    jxyz

    09/05/2022, 11:44 PM
    getting this cors result in my browser for my hello-world
    g
    • 2
    • 2
  • Function Pricing
    v

    Vengeance

    09/06/2022, 1:01 AM
    Hi. I see for $25 a month is 2 million invocations, how much is the pay-as-you-go for invocations after that?
  • How to use OAuth for Twitter from iOS apps or Swift?
    d

    d33pu

    09/06/2022, 6:47 AM
    I've tried to dig into documentation, there seems to be no code samples around OAuth for Swift. I was wondering if there is an example to understand what data client should send for successful third part sign ups and sign in. Thank you!
    a
    • 2
    • 2
  • Edge Function - User authentication from Bearer - how to?
    b

    boeledi

    09/06/2022, 7:01 AM
    Hello, I am trying to identify the caller of an Edge Function, but I systematically get a "null" value. Here is what I do: * On the client side (Flutter), once the user has signed in, I am invoking the function
    Copy code
    FunctionResponse? res;
        final String? accessToken = Supabase.instance.client.auth.session()?.accessToken;
    
        try {
          res = await Supabase.instance.client.functions.invoke(
            'ef_authentication_test',
            body: {
              "action": "action",
              "data": {
                "hello": "worled",
              },
            },
            headers: {'Authorization': 'Bearer $accessToken'},
          );
    
          TraceHelper.logE('[SupabaseHelper::invokeFunction] -- Response', error: res);
          
        } catch (e) {
          TraceHelper.logE('[SupabaseHelper::invokeFunction] -- Exception', error: e);
        }
    The call invocation works, the exists. At the level of the Edge Function, I am running the following:
    Copy code
    export const supabaseClient = createClient(
      // Supabase API URL - env var exported by default when deployed.
      'https://KEY.supabase.co',
      // Supabase API ANON KEY - env var exported by default when deployed.
      '<ANON KEY>'
    );
    
    export function supabaseUser(req:Request) {
      // Get the authorization header from the request.
      const authHeader = req.headers?.get('Authorization')?.replace("Bearer ", "") || "";
      console.log(`Authorization: ${authHeader}`);
      
      supabaseClient.auth.setAuth(authHeader);
    
      console.log(`User: ${supabaseClient.auth.user()}`);
    
      return supabaseClient.auth.user();
    };
    The corresponds to the from the client side. The I am getting is always NULL. => I need to get this to validate the requestor. Could anybody tell me what I am doing wrong? Thanks in advance,
    p
    • 2
    • 2
  • RLS and trigger functions
    d

    draco

    09/06/2022, 8:19 AM
    Is there a way to call a function ( defined in Database -> Functions ) from your rls policy if that function returns a bool?
    s
    • 2
    • 2
  • Strip EXIF from uploaded images in Storage
    w

    whiskeywizard

    09/06/2022, 9:29 AM
    Hi, Is it possible to automatically strip any EXIF metadata from uploaded images when uploading to Storage? Or would I have to upload to my own endpoint which strips it, then upload to Supabase on the backend. I think a lot of users are going to use Storage for images without realizing that images often contain GPS data. Thanks.
    g
    a
    • 3
    • 2
  • update() not returning records
    g

    gorbypark

    09/06/2022, 11:23 AM
    Not sure if I'm doing something wrong, but
    update()
    is not returning any data and the docs say by default it returns the updated record. Also, the returning property does not seem to exist as per the docs.
    .update({val: 123}, {returning: 'representation})
    and TS complains that only
    count
    is valid. The data is actually being updated in the database. In the below code, the
    if (data) {}
    condition never fires, and the first console.log always returns undefined. If i force an error, error is working as expected.
    Copy code
    js
          const { data, error } = await supabase.from('inventory').update(newRow).match({ id: newRow.id })
    
          console.log('data below await', data)
    
          if (data) {
            console.log('data from inside conditional', data)
          }
    
          if (error) {
            console.log('error!', error)
          }
    h
    g
    • 3
    • 4
  • DataDog integration
    r

    rbkayz

    09/06/2022, 12:08 PM
    Hi folks, any way to get a datadog agent running on our postgres db, so we can track health?
  • Cloning a project or a db
    g

    gbb

    09/06/2022, 12:18 PM
    Hey, I want to switch from dev to production, and most of my db was made using the interface instead of sql queries. I'd love to know if there's a way of cloning the database to a new project or creating a similar one, or at least clone the tables. I couldn't find anything on that yet. If there isn't, can someone help me with some sort of workaround on how to extract everything about my db (except the data itself, like the entries) and spawn a new one? I would greatly appreciate it!
    s
    • 2
    • 1
  • JWT authenticated storage example
    g

    gwaiLoFi

    09/06/2022, 3:07 PM
    Hiya, I'm using Supabase storage with a NextJS TypeScript app. I want to require authentication for all requests to/from my buckets from my app and I assume I can accomplish this with a Supabase JWT Bearer Token header, but are there any robust examples out there? I assume I can piggyback this off of the Supabase client? Have been digging through the docs but I'm finding fragments of what I need here and there, any additional guidance would be appreciated 🙂
    g
    • 2
    • 2
  • Why isn't this working,
    h

    Honeyandtoast

    09/06/2022, 3:31 PM
    var src = ('') const { data, error } = supabase.storage .from('picsprofile') .download('client/img/A027.jpg') var src = URL.createObjectURL(data) console.log(src)
    g
    • 2
    • 3
  • An Error has occurred Failed to fetch
    h

    Hand0fThrawn

    09/06/2022, 3:44 PM
    Hello, I'm trying to edit a table, specifically enabling real-time and changing the default value for one of the rows. However every time I hit save I get a Failed to fetch error. Then when I attempted to create a new table I get the same error! Should I start a whole new project? Thoughts?
    g
    • 2
    • 7
  • Example nextjs-ts-user-management repo doesn't work out of the box in local dev
    g

    gwaiLoFi

    09/06/2022, 4:34 PM
    https://github.com/supabase/examples/tree/main/supabase-js-v1/user-management/nextjs-ts-user-management Steps I followed to run this example locally: 1. set env variables for supabase 2.
    yarn
    3.
    yarn dev
    yarn dev fails with missing types warning, suggests`yarn add --dev @types/react @types/node` 4. install node + react types 5. run
    yarn dev
    continuously get this error:
    Copy code
    It looks like you're trying to use TypeScript but do not have the required package(s) installed.
    
    Please install @types/react and @types/node by running:
    
            yarn add --dev @types/react @types/node
    s
    • 2
    • 2
1...161718...230Latest