https://supabase.com/ logo
Join DiscordCommunities
Powered by
# help-and-questions
  • Can't update user's metadata in server
    h

    Hal

    10/20/2022, 8:36 AM
    For some reason I have to handle the user stuff in server. I tried to update user's metadata in server but it failed. I initialized supabase with custom headers since
    setAuth
    is not available in V2. My code is based on [this issue](https://github.com/supabase/supabase/issues/8490#issuecomment-1219766620). But it returned
    AuthSessionMissingError: Auth session missing!
    . I tried the service role key it's the same result.
    s
    g
    r
    • 4
    • 7
  • Success updating with status 204, but logged data is null
    r

    Ridho

    10/20/2022, 10:13 AM
    I was updating a row, it was successfully updated, but when i log the result, the data is null. here's my code: model
    Copy code
    javascript
    updateExperience: (id, title, company, detail, startDate, endDate) =>
        new Promise((resolve, reject) => {
          supabase
            .from("experience")
            .update({
              title,
              company,
              detail,
              start_date: startDate,
              end_date: endDate,
            })
            .eq("id", id)
            .then((result) => {
              if (!result.error) {
                resolve(result);
              } else {
                reject(result);
              }
            });
        }),
    and in controller:
    Copy code
    javascript
    const result = await experienceModel.updateExperience(
            experienceId,
            title,
            company,
            detail,
            startDate,
            endDate
          );
    when i log the result:
    Copy code
    bash
    {
      error: null,
      data: null,
      count: null,
      status: 204,
      statusText: 'No Content'
    }
    when i check the table, data is updated but the log didn't show it. i do the same way in my last project, and it was fine.
    n
    g
    • 3
    • 5
  • Vercel supabase with edge functions
    w

    wiesson

    10/20/2022, 10:23 AM
    Is anyone using Vercel Edge functions with supabase?
    Copy code
    /dashboard
    12:18:47:08
    Error: supabaseUrl is required.
        at ../../../../node_modules/.pnpm/@supabase+supabase-js@2.0.2/node_modules/@supabase/supabase-js/src/SupabaseClient.ts:87:28
        at ../../../../node_modules/.pnpm/@supabase+supabase-js@2.0.2/node_modules/@supabase/supabase-js/src/index.ts:38:9
    It seems that the supabase environment var is empty, but it works with the regular functions. Does anyone know what I could do?
    n
    • 2
    • 7
  • Issue with running 'supabase start'
    a

    Afkop-sonneblom

    10/20/2022, 11:50 AM
    Hey there! I seem to be having trouble with running the supabase cli's "supabase start" command. "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" Which is strange because I have no issue running "docker ps" and any other docker containers, and docker desktop is definitely running. I've also tried running the supabase cli with sudo, same issue. I am using macOS with an M1 Pro, and using Supabase CLI 1.10.2, docker 20.10.20, and node 18. Any help would be appreciated πŸ™‚
    l
    o
    d
    • 4
    • 12
  • Easiest way to move between on-prem and hosted solutions
    f

    futurmaster

    10/20/2022, 1:19 PM
    Hi everyone, I'm curious if there is any way to migrate between on-prem (aka self-hosted) easily and hosted versions of Supabase? I mean an automated way to copy all the configs, content and enabled extensions.
  • HCaptha
    m

    mattposgate

    10/20/2022, 1:33 PM
    Hi All, 2 questions about auth and captchas - latest js versions. Can I re-use a captcha token, eg for resetPasswordForEmail followed by verifyOtp ? I'm getting 'AuthApiError: request disallowed' for verifyOtp during verify signup, since adding captchas and regardless of whether I re-use the captcha or not. Captchas are working for sign-in, ie signInWithPassword. Not sure why. The call is as follows: const authResponse = await supabaseClient.auth.verifyOtp({ email, token: otp, type: "signup", options: { captchaToken }, }); Any thoughts?
  • How would you disable a supabase user (as opposed to removing it)?
    y

    YelloJello

    10/20/2022, 1:38 PM
    Is it possible to add/remove some role to prevent a user that has an supabase account from logging in anymore? I do not want to remove the account because that would result in a cascade where all it's data and any data authored by that user will be deleted. This needs to happen only for a certain subclass of users, which is why I wouldn't wanna change any cascade policies.
    g
    n
    • 3
    • 11
  • How to get fresh auth token?
    c

    Cheqo

    10/20/2022, 2:41 PM
    I managed to update user custom claims from my server with this method:
    Copy code
    await supabaseAdmin.auth.admin.updateUserById(user.id, {
            app_metadata: {
              role: 'super-premium'
            }
    I just wanted to know, how to make sure that these changes are reflected immediately in my user token? is there a method that I can call like
    auth.refreshToken()
    or something like that?
    g
    j
    • 3
    • 5
  • onAuthStateChange SIGNED_IN event not firing after OAuth
    s

    simpautus

    10/20/2022, 2:52 PM
    I have a onAuthStateChange subscription in a useEffect hook of my Remix.run app root component. I recently updated my project to use Supabase v2 and now I'm experiencing weird behavior with OAuth signin/signup. Sometimes the SIGNED_IN event is fired almost immediately and everything seems normal but sometimes I get returned to the correct route but nothing happens. Then I might visit another browser tab and when I open my Remix app tab again without any other user action I get signed in. It seems to me like the event (SIGNED_IN) is fired with inconsistent delay. Any help with this? Here's the hook I place in the root component.
    Copy code
    export function useAuthStateChangeSubscription() {
      const fetcher = useFetcher()
      const [searchParams] = useSearchParams()
      const redirectTo = searchParams.get('redirectTo') ?? ROUTE_HOME
    
      useEffect(() => {
        const {
          data: { subscription: listener },
        } = supabase.auth.onAuthStateChange((event, session) => {
          console.log(event)
          if (event === 'SIGNED_IN') {
            const accessToken = session?.access_token
            const refreshToken = session?.refresh_token
    
            if (!accessToken) return
    
            const formData = new FormData()
    
            formData.append('accessToken', accessToken)
            formData.append('refreshToken', refreshToken || '')
            formData.append('redirectTo', redirectTo)
    
            fetcher.submit(formData, {
              method: 'post',
              action: '/api/auth/login',
              replace: true,
            })
          }
          if (event === 'SIGNED_OUT') {
            fetcher.submit(null, {
              method: 'post',
              action: '/api/auth/logout',
              replace: true,
            })
          }
        })
    
        return () => {
          listener?.unsubscribe()
        }
      }, [fetcher, redirectTo])
    }
    j
    j
    n
    • 4
    • 60
  • supabasejs is returning unknown type for nested tables
    t

    Thoth Trismegistus

    10/20/2022, 3:24 PM
    how do i make the return type as a specific type?
  • supabase-js timing out for the last 8 hours
    g

    Greg

    10/20/2022, 3:26 PM
    Starting at 3am EST, my app started timing out on all requests. I've been using supabase-js v1.35.6 and also tried with the new v2.0.2, getting same error The db works just fine when running SQL queries, so I think its a Supabase API bug. It times out after 30 seconds and returns unformatted HTML as the error message, with 522 status Database health is normal. Memory usage hovers around 60% with < 1% CPU usage and < 80% storage used The frontend also wont load which seems related
    g
    • 2
    • 12
  • What is the problem in my phone auth?
    t

    teiki

    10/20/2022, 5:21 PM
    const signIn = async() => { let { user, error } = await supabase.auth.signInWithOtp({ phone: '+xxx' }) } const verify = async() => { let { error } = await supabase.auth.verifyOtp({ phone: '+xxx', token: 'xxx' }) } I get the code, but cannot verify it. I get the following error: AuthApiError: Verify requires a verification type at /home/runner/My-proj/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:41:20 { __isAuthError: true, status: 400 }
    g
    • 2
    • 4
  • Having multiple join tables how to specify which one should be used (js client)?
    t

    tyakymiuk

    10/20/2022, 5:28 PM
    lets imagine such a case (its not the real one but the question relates to similar problem): I have 4 tables: user_profiles, locations, liked_by_user_locations, disliked_by_user_locations (liked_by_user_locations and have same shape with user_id and location_id) when quering photos I want to add array of likes and dislikes but it's not clear to me how to pick a specific join table db.from('user_profiles') .select(
    Copy code
    *,
      likedLocations:locations ??how to specify here to use  liked_by_user_locations table?? (
        *
      ),
      dislikedLocations:locations ??how to specify here to use  disliked_by_user_locations table?? (
        *
      )
    )
    s
    • 2
    • 3
  • Do you have to return row to access data using update method?
    l

    Lukas V

    10/20/2022, 5:58 PM
    I am migrating to v2 and the default behaviour right now for
    .insert() / .upsert() / .update() / .delete()
    methods is not to return any rows. If I want to check if method was successful, do I have to include
    .select()
    ? Because it's seems like otherwise
    data
    will be undefined.
    Copy code
    const { data: updateSuccess, error: updateError } = await supabase
    .from('users')
    .update({
      id: user.id,
      full_name: "James Bond",
    })
    
    if (updateError) {
    toast.error('Error updating profile, please try again');
    }
    if (updateSuccess) {
    toast.success('profile updated!');
    }
  • Checking for counts in RLS
    l

    LufyCZ

    10/20/2022, 6:19 PM
    Hey, I've got a table with 3 rows (which matter) ID = PK user_id=uuid lesson=int I want a user to only be allowed to create a new row if they don't have that specific lesson yet. (+ they can only create a row for their user_id) This can't happen: id: 1; user_id=1; lesson=1 id: 2; user_id=1; lesson=1 This can happen: id: 1; user_id=1; lesson=1 id: 2; user_id=1; lesson=2 I've currently got this in the CHECK part:
    Copy code
    sql
    ((SELECT count(*) AS count
       FROM "lectureSeats" "lectureSeat"
      WHERE (("lectureSeat".user_id = uid()) AND ("lectureSeat".lecture = 1))) <= 1)
    Problem is, I can't seem to get the
    ("lectureSeat".lecture = 1)
    part right, when I try
    ("lectureSeat".lecture = lecture)
    it just replaces it with
    ("lectureSeat".lecture = "lectureSeat".lecture )
    which is of course always true and doesn't work. How do I get that newRow.lecture in there? Thanks
  • trying to edit a supabase function with dbeaver
    s

    stefikira

    10/20/2022, 7:37 PM
    Hi, I'm trying to edit/save a function with DBeaver. The function was created with supabase web dashboard, for a trigger(copy user from
    auth.users
    to
    public.users
    ), but when I'm trying to save it, I get this error
    Copy code
    ERROR: must be owner of function add_user
    . I'm guessing that it has to do with the roles, but I have no idea what to tweak.
  • I need to use `context` within the parameters to `withPageAuth`
    u

    user8923

    10/20/2022, 8:22 PM
    Copy code
    export const getServerSideProps = withPageAuth({ redirectTo: '/login' })
    withPageAuth
    is called with an object that includes the
    redirectTo
    attribute. I need to use the context passed to
    getServerSideProps
    within that attribute, in order to concatenate
    context.resolvedUrl
    to the
    '/login'
    value. How can I do that in the most elegant manner?
    j
    • 2
    • 34
  • Magic link email
    m

    mumbles

    10/20/2022, 8:45 PM
    Is there a way to include the email as part of the magic link query params?
  • Easiest Way To Sync Data from CSV Into Existing Table?
    c

    czypnt

    10/20/2022, 9:22 PM
    Is there an easy way to do this? I have data on a google sheets that I want to import into my supabase table that already exists (I know about import via csv on new tables)
  • Read Replica Adoption at company using current Postgres
    e

    Elgr

    10/20/2022, 9:43 PM
    I'm new to Supabase and I'm thinking through adoption at my company. Since we're already using postgres, my thinking was that we would create a read replica of our current postgres, and I'd be able to show how the real time Read features of supabase benefit our product. Has anyone gone through a similar path? I'm hoping to avoid any major interruptions or conflicts with other teams going the read replica route
  • How to access bucket files with anon key and RLS?
    o

    Ok-Panda4332

    10/21/2022, 4:48 AM
    1. I want to have read access with anon key. But creating a basic policy as below gives me access denied error.
    Copy code
    create policy "Read access."
    on storage.objects for select using (
        bucket_id = 'bucketname'
        and auth.role() = 'anon'
    );
    Copy code
    URL - https://xyz.supabase.co/storage/v1/object/sign/bucketname/file.txt?token=anonkey
    I am having trouble writing SQL command for it. 2. Also if I make my bucket public without any RLS, can others only read the documents or can they edit and upload to the bucket?
  • Row level security and sorting on foreign tables
    x

    Xenni

    10/21/2022, 5:10 AM
    So I'm starting my first little project on Supabase and am attempting to remove all need to write CRUD functions bar some more exotic stuff. The issue with this however is that RLS won't stop a user from updating a column such as
    updated_at
    or worse
    role
    meaning that we need to store those in
    entity_meta
    tables with read-only permissions. In doing this though we now are unable to perform sorting since sorting on a foreign table value isn't currently supported with PostgREST afaik. Am I going crazy or is there a better pattern for these things?
    g
    • 2
    • 2
  • Next.js setup docs are incorrect?
    a

    Austin

    10/21/2022, 5:31 AM
    I've noticed I'm unable to complete an app build following the /with-nextjs 1. Wrap your pages/_app.js component with the SessionContextProvider component: This is incorrectly ported and has a formatting error; refer to https://supabase.com/docs/guides/auth/auth-helpers/nextjs for the correct one. 2. Add the Auth component to your home page: I can't seem to get this to work. I don't have my app configured for typescript. Am I able to get these working without it?
    Copy code
    import **type** { NextPage } from 'next'
    import { Auth, ThemeSupa } from '@supabase/auth-ui-react'
    import { useSession, useSupabaseClient } from '@supabase/auth-helpers-react'
    
    const Home: NextPage = () => {
      const session = useSession()
      const supabase = useSupabaseClient()
    
      return (
        <div className="container" style={{ padding: '50px 0 100px 0' }}>
          {!session ? (
            <Auth
              supabaseClient={supabase}
              appearance={{ theme: ThemeSupa }}
              theme="dark"
            />
          ) : (
            <p>Account page will go here.</p>
          )}
        </div>
      )
    }
    
    export default Home
    j
    s
    • 3
    • 10
  • Download GraphQL Schema
    a

    Arne

    10/21/2022, 6:17 AM
    Hi! I'm using the local development setup and would like to download the generated GraphQL schema. I ran
    select graphql.rebuild_schema();
    . Then I try to download the schema using
    Copy code
    curl --request GET 'http://localhost:54321/graphql/v1' \                  
    -H 'apikey: eyJhbG...' \                                                                             
    -H 'Authorization: Bearer eyJhbG...'
    As result I get:
    Copy code
    {
      "code": "PGRST202",
      "details": null,
      "hint": "If a new function was created in the database with this name and parameters, try reloading the schema cache.",
      "message": "Could not find the public.graphql() function in the schema cache"
    }
    Obviously there should be no
    public.graphql()
    function. How should I modify my request to get the GraphQL schema?
  • Preventing OTP auth sign in abuse?
    w

    willsch

    10/21/2022, 7:06 AM
    I'm using phone numbers with OTP to log users into my app. This requires an SMS to be sent for each login attempt. I'm concerned that a malicious user could abuse the signin() endpoint costing me a lot of money. What's the right way to prevent that from happening?
    s
    • 2
    • 1
  • Supabase v2 implementation for OpenID Connect
    c

    Chi__no

    10/21/2022, 7:06 AM
    https://github.com/supabase/gotrue-js/pull/207 I have tried to implement OpenID connect using this thread as a reference. Is it not compatible with supabase v2? I would like to login with the following command.
    Copy code
    //native sign in
            GoogleAuth.signIn().then((res) => {
                this.supabase.auth
                    .signIn({
                        oidc: {
                            id_token: res.authentication.idToken,
                            provider: "google",
                γ€€γ€€γ€€γ€€γ€€γ€€γ€€γ€€nonce:"some string"
                        },
                    })
                    .then((res) => {
                        console.log("supabase res");
                        console.log(res);
                    });
            });
    s
    i
    d
    • 4
    • 8
  • getting null value while selecting data from the table
    a

    Ansh-Rathod

    10/21/2022, 7:26 AM
    hii, i crated my own table auth table (Users) in public schema but i created this table using SQL editor, when i try to select data from the table im getting null response.
    Copy code
    const { data } = await supabase
          .from("Users")
          .select("username,hashpass")
          .match({ username: req.body.username });
    here data is null.
    and when i create the table with from supabase ui it works fine! found something similar issue on github but didn't understand it properly. https://github.com/supabase/supabase/discussions/5432
  • Use upsert(dataset) or insert(dataset, {upsert true})
    j

    jkohlin

    10/21/2022, 8:39 AM
    Is there a difference between these two, or is one of them going to be deprecated? Both are in the docs.
    s
    • 2
    • 2
  • how can I create new table or new function in Supabase using REST API?
    t

    therakeshpurohit

    10/21/2022, 9:20 AM
    how can I create new table or new function in Supabase using REST API?
    s
    • 2
    • 1
  • RLS policy for insert to check given column value?
    a

    arcavid

    10/21/2022, 9:51 AM
    Can get a column value for an insert command and use it in a policy's with check based on the value? For example, if a column name is color, then I would like to allow the insertion only if the value is 'red'.
    s
    g
    • 3
    • 3
1...495051...230Latest