https://supabase.com/ logo
Join Discord
Powered by
# javascript
  • b

    battlesheep123

    06/26/2022, 11:46 AM
    This is more an architectural question instead of an authentication / authorization question. The questions is: Would you use the supabase client directly in your frontend app, e.g. SvelteKit? Or would you rather have a separate backend API that is doing the supabase access?
    s
    • 2
    • 1
  • g

    GΓΌnhan

    06/26/2022, 12:16 PM
    hey guys i hope you are doing okay, I was trying to use not and in filters together, and at first i could not manage to make it first. Could you please help me what was my fault in the first example?
    Copy code
    const { data: randomAnswers, error: answersError } = await this.$supabase.from('random_answers').select('id, text').not('id', 'in', `(${currentAnswersInHandsIDs})`)
    this gave me, first error. but this worked.
    Copy code
    const { data: randomAnswers, error: answersError } = await this.$supabase.from('random_answers').select('id, text').not('id', 'in', `(${currentAnswersInHandsIDs.join(',')})`)
    docs says i can use js array, why my first code did not work? any ideas? thank you very much.
    g
    • 2
    • 1
  • s

    silentworks

    06/26/2022, 1:47 PM
    This is more an architectural question
  • g

    garyaustin

    06/26/2022, 2:29 PM
    .not and embedded array
  • t

    tylergannon

    06/26/2022, 5:32 PM
    Hi all - is there an interface to Supabase that would allow me to supply the auth token on each request, rather than having to use
    signIn()
    to fully instantiate the client? I'd like to be able to use the
    SupabaseClient
    on my API server. Clients send the JWT and refresh token in an HttpOnly cookie. The trick is that I don't know how to authorize the
    SupabaseClient
    object without calling
    signIn()
    . I'm hoping to be able to avoid that extra trip to Supabase on every API call, and I don't want to keep an open SupabaseClient object for each session.
    g
    • 2
    • 2
  • t

    tylergannon

    06/26/2022, 5:37 PM
    A related question would be: Are there any plans for a Supabase adapter for Svelte Kit, which would export Svelte Kit endpoints to Supabase functions?. That sounds tricky but something in that area could be pretty useful.
  • s

    stijn

    06/26/2022, 9:08 PM
    Hi! When using the Javascript Supabase package with
    persistSession: true
    , it stores the session in localStorage which isn't great security wise. While I'm not sure it's 100% safe I thought it might be better to instead store the refresh-token in a cookie and use this to persist the session? Is it possible to authenticate with a refresh token? Does anybody know other/better ways to securely persist session? All advice and related resources are appreciated:)
  • d

    Devr

    06/28/2022, 12:21 PM
    Hey there this might be a very-obvious or dumb question as am new to authentication system and stuff.., But I wanted to ask that for how much long does supabase store the user's session after SignIn or for how long will he be signed in to my web page? or do we have to set it by cookies? Thanks!
    j
    • 2
    • 2
  • j

    jaitaiwan

    06/28/2022, 2:45 PM
    How long are sessions?
  • l

    lumen

    06/29/2022, 12:57 PM
    Supabase Auth and Next.js SSR: User redirected back to my website after logging in sees the logged out version of the page. Hi! I am using Next.js and Supabase Auth to build a platform for selling courses. When the user is logged in and has bought the course, I want to show them the content. When the user is logged out, I want to show them the paywall. It is important to me that course content is server-side rendered. I am checking whether the user is logged (and whether they own the course) inside
    getServerSideProps()
    like so:
    Copy code
    javascript
    import { getUser } from '@supabase/auth-helpers-nextjs'
    import prisma from 'prisma/prismaClient'
    
    export async function getServerSideProps({ params, req, res }) {
      // Check whether the user owns this course
      let ownsCourse = false
      const { user } = await getUser({ req, res }) // Access the user object
      if (user) {
        const profile = await prisma.profile.findUnique({
          where: { id: user.id },
          include: { courses: true },
        })
        ownsCourse = profile.courses.some((c) => c.courseId === courseSlug)
      }
      [...]
    }
    My problem is that when the user logs in, and is redirected back to my website, they still see the logged out version of the page (with the paywall). They have to reload the page manually to see the signed in version. I'm guessing that happens because after the user is redirected back to my website,
    getServerSideProps()
    sees that they don't have any auth cookies yet, so it renders the signed out version of the page. Then the frontend code realizes that I just logged in, and sets the auth cookies, but at this point the page has already been rendered. Can you please share some advice? How can I solve this?
  • m

    Miguel Espinoza

    06/29/2022, 5:55 PM
    Howdy, just want to get a better understanding of how initializing the supabase js client works. I'm working on a chrome extension and have the usual oAuth flow working with a website and sending token/refreshToken to the extension via
    chrome.runtime.sendMessage
    I was under the impression I had to sync session tokens between my extension background and content_script, but after some fiddling and using
    supabase.auth.onAuthStateChange
    I noticed supabase takes care of that. In other words, I'm initializing supabase in the background and without any additional code, supabase in the content_script is initialized. Kinda neat! I imagine there's some message handling? I was checking if anyone is familiar with this behavior and if there are docs to help clarify this. My main concern is ensuring that the refresh_token is in sync between the background and content_script. Thanks!
    • 1
    • 2
  • m

    Miguel Espinoza

    06/29/2022, 6:06 PM
    Chrome Extension and Supabase initialization
  • h

    helewud

    06/29/2022, 6:42 PM
    Hey everybody, I am a bit stuck with invalidating access tokens on supabase server side. I have tried using the signOut() method but the access token doesn't get invalidated. If you have implemented this (invalidating access tokens) before, can you show me how? Is there a standard practice to go about it?
    g
    • 2
    • 1
  • g

    garyaustin

    06/29/2022, 10:03 PM
    Invalidate access tokens
  • o

    ole

    06/30/2022, 8:15 PM
    Copy code
    export const getStaticProps = async () => {
      const {data:product} = await supabase.from("products").select('*')
      return {
        props: {
          product,
        },
      };
    };
  • o

    ole

    06/30/2022, 8:16 PM
    could someone tell me why this is returning undefined even tho i have data in my table?
    s
    • 2
    • 1
  • s

    silentworks

    06/30/2022, 11:00 PM
    could someone tell me why this is
  • s

    Shoki

    07/01/2022, 2:55 PM
    hi, these queries are working :
    Copy code
    js
        const { data } = await supabase
          .from("images_metadata")
          .select()
          .contains("tags", [text])
    
        const { data } = await supabase
          .from("images_metadata")
          .select()
          .like("title", text);
    but i would like to use
    contains
    and
    like
    at the same time like this:
    Copy code
    js
        const { data } = await supabase
          .from("images_metadata")
          .select()
          .contains("tags", [text])
          .like("title", text);
    so this query will return all the elements which contains
    text
    in
    tags
    and
    text
    in
    title
    is it possible ?
    g
    • 2
    • 6
  • r

    rchrdnsh

    07/01/2022, 5:05 PM
    Hello everybody πŸ™‚ I am learning supabase and an trying to figure out how to integrate it with stripe elements and billing and processing in general...I'm using svelte/kit for the app... Just curious if anybody has any experience merging those things together and if they have any thoughts/advice/resources they wouldn't mind sharing πŸ™‚ thank you! XD
    r
    • 2
    • 1
  • g

    garyaustin

    07/01/2022, 5:59 PM
    Multiple filters
  • k

    kresimirgalic

    07/01/2022, 6:55 PM
    hey guys, i am trying to get all rows between two dates where format is YYYY-MM-DD, this is what i used but its not working, any suggestions?
    Copy code
    const { data, error } = supabase
          .from('project_time_entries')
          .select(`*, project: project_id(*), client: client_id(*)`)
          .rangeGt('work_date', [
            dayjs(date[0]).format('YYYY-MM-DD'),
            dayjs(date[1]).format('YYYY-MM-DD'),
          ])
    r
    • 2
    • 1
  • r

    Relisora

    07/02/2022, 9:38 PM
    From my JavaScript client, some requests work and some don't... I organized materialized views per year. So I have
    MV_2021
    ,
    MV_2022
    etc... Now I have one request that does this:
    Copy code
    js
    .from(`MV_${this.year}`)
    .select(
      `
        *,
        clients:b_client_id!inner(id, name, slug, image_filename)
      `
    )
    .eq('a_client_id', this.client.id)
    It basically represents every relation each client had with every client. I want the stats of the relations of one client. The issue is that... Sometimes it works and sometimes not, my
    MV_2021
    works but not
    MV_2022
    nor
    MV_2021
    . I created them all with the same query just changing the year, and I already tried deleting them all and creating them, different views work but never all of them. The error message is:
    Could not find a relationship between 'MV_2022' and 'b_client_id' in the schema cache
    The query for every year works all the time if I try them in raw SQL. Can someone please help? I ran out of options to try
    s
    • 2
    • 33
  • r

    Relisora

    07/02/2022, 9:44 PM
    Hello everybody πŸ™‚
  • r

    Relisora

    07/02/2022, 9:46 PM
    hey guys i am trying to get all rows
  • s

    sebx

    07/03/2022, 8:39 AM
    Officially losing it. Cannot figure out why I'm not able to query database from supabase js client... even with service role key! RLS disabled.
    r
    j
    • 3
    • 2
  • r

    Relisora

    07/03/2022, 10:32 AM
    Officially losing it Cannot figure out
  • r

    Roshan J.

    07/03/2022, 11:57 AM
    Facing an issue in using realtime feature of Supabase DB: I followed the steps while trying to practise supabase: 1) Created the project and database as per my requirements 2) Row level security is disabled and realtime operations are allowed for the table in which I want to insert content 3) Unable to understand how to add the subscription as well as remove subscription related code block inside useEffect with confusions about the dependency Here is a codesandbox repo to help understand the problem: https://codesandbox.io/s/white-surf-hysdet?file=/src/App.js
    g
    • 2
    • 4
  • y

    yaman

    07/03/2022, 12:02 PM
    Hey guys, did someone experienced an issue where the session is not set after a login with Supabase Auth? I do get the supabase.auth.user() user object but not the one from the "useUser" hook with Next.js. Only if I go to another tab and back to my localhost session, I receive the user object from useUser.
    j
    • 2
    • 1
  • y

    yaman

    07/03/2022, 12:02 PM
    Someone knows how to fix this?
  • y

    yaman

    07/03/2022, 12:03 PM
    P.S.: even API routes won't work with then authentication function wrapped around the handler
1...666768...81Latest