https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Error Inviting User After RLS Policy Query
    b

    brassotron

    11/02/2022, 12:59 AM
    I'm trying to add user management to a local Supabase instance and I'm running into an error relating to RLS policies. With a blank database, if I run the following from the SQL editor, it executes without error.
    Copy code
    sql
    create table public.profile (
      profile_id uuid references auth.users not null primary key,
      first_name text,
      last_name text,
      created_at timestamp with time zone default now(),
      updated_at timestamp with time zone
    );
    
    alter table public.profile
      enable row level security;
    
    create policy "Users can select their own profile." on public.profile
      for select using (auth.uid() = profile_id);
    
    create policy "Users can insert their own profile." on public.profile
      for insert with check (auth.uid() = profile_id);
    
    create policy "Users can update own profile." on public.profile
      for update using (auth.uid() = profile_id);
    
    create function public.handle_new_user()
    returns trigger as $$
    begin
      insert into public.profile (profile_id, first_name, last_name)
      values (new.id, new.raw_user_meta_data->>'first_name', new.raw_user_meta_data->>'last_name');
      return new;
    end;
    $$ language plpgsql security definer;
    create trigger on_auth_user_created
      after insert on auth.users
      for each row execute procedure public.handle_new_user();
    But if I then try to invite a user via the Supabase dashboard, I get this error:
    Copy code
    Failed to invite user: Database error finding user
    However, in the above if I change:
    Copy code
    sql
    create policy "Users can select their own profile." on public.profile
      for select using (auth.uid() = profile_id);
    to
    Copy code
    sql
    create policy "Users can select their own profile." on public.profile
      for select using (true);
    It allows me to invite users without error? Thanks for any help!
    g
    s
    • 3
    • 10
  • An invalid response was received from the upstream server
    p

    PhilipWee

    11/02/2022, 1:29 AM
    I'm facing this error, I'm quite sure the error is being thrown from kong, I've restarted supabase but it still isn't working Does anyone have any ideas how I could fix it? Its only an issue on my staging environment but production seems to be working fine It only seemed to stop working once I changed my base URL
  • Disable sign-ups from external website
    w

    Walrusking

    11/02/2022, 2:28 AM
    Is there a way to disable sign-ups from my own website? I can't find anything in the management api about it. I was thinking about storing a value in the database and disabling the registration page if it exists in the settings, but I want to make sure people can't just go to the api directly to sign up
    g
    • 2
    • 35
  • Property .on does not exist on supabase?
    b

    Blobby

    11/02/2022, 2:36 AM
    Trying to add a listener to realtime DB updates in a useEffect. Getting this error:
    Property 'on' does not exist on type 'PostgrestQueryBuilder<any, any>'.ts(2339)
    Copy code
    javascript
    
    import { useSessionContext } from '@supabase/auth-helpers-react';
    
    const Component() => {
    const { session, supabaseClient } = useSessionContext();
    
    useEffect(() => {
        const subs = supabaseClient
          .from("objects")
          .on("UPDATE", (payload) => {
            // dispatch(updateGameObject(payload.new.data));
          })
          .subscribe(console.log);
        subs.onClose(() => {
          console.log("on closed");
          supabase.removeAllSubscriptions();
        });
        return () => {
          subs.unsubscribe();
        };
      }
    g
    • 2
    • 8
  • Can I pay-as-you-go from the beginning?
    a

    alanpham

    11/02/2022, 3:55 AM
    As the title suggests, instead of having to pay $25 per month, can I just have my project in pay-as you-go mode? The idea is that I will use the storage more than the database itself so I just want to pay for the storage which according to the pricing table, it's $0.021 per GB. Any help is appreciated
    g
    j
    • 3
    • 4
  • (supabase_flutter) Recover Password gets server error 500
    d

    Desmond

    11/02/2022, 8:48 AM
    So in my app, when the user enters their email address in the login screen, they can ask for a password recovery. This then calls the resetPasswordForEmail() API. However, this always gives back a server error 500: error = AuthException(message Unable to process request, statusCode 500) The supabase client is correctly initialized (other API calls work just fine). I can make a minimal example, if that helps. Many thanks.
  • SQL query help
    b

    Bamsespartymix

    11/02/2022, 9:11 AM
    Hi! Dev student here, new to both Supabase and databases in general. Trying tro write a function with SQL but get the error "syntax error at or near "" ". Can't figure out what i am doing wrong.. help pls! 🙏
    Copy code
    create or replace function get_dates(user_id_input uuid, friend_id_input uuid) returns setof record language sql as $$ 
    SELECT date, COUNT(date)
    FROM available_dates
    where user_id = (user_id_input)
    or user_id = (friend_id_input)
    GROUP BY date
    HAVING COUNT(date) > 1;
    $$;
    g
    • 2
    • 7
  • Comparing Arrays in Where or Having Clause
    s

    STILLWATER;

    11/02/2022, 10:22 AM
    I want to check if given array_agg(column) is in the array of arrays I sent in the rpc, consider following: I want to check if ['A','B'] is in [['A','A'],['A','B']] I looked around for array comparision in psql just found <@ and the && operator for checking subset or overlaping i.e exact arrays, how do I check if array is IN the array of arrays?
    f
    • 2
    • 16
  • Elixir Ecto db connection
    o

    oliver-kriska

    11/02/2022, 12:50 PM
    Hello, when I connect my app with supabase database with database url I can not make queries. I got error that
    prepared statement "ecto_5765" does not exist
    and similar. Any idea what can be wrong?
    • 1
    • 1
  • Using now() in from().update()
    t

    tpz

    11/02/2022, 2:05 PM
    Hi! In knex, I could easily do ``knex('updates').update('updatedAt',knex.fn.now()).where('id',1);``. How can I use now() function in .update()? Is it possible? ``supabase.from('updates').update({ updatedAt: now() }).eq('id',1);`` Thanks
    j
    e
    s
    • 4
    • 5
  • postgres function that automatically updates value without being called?
    t

    Thoth Trismegistus

    11/02/2022, 2:13 PM
    Can you have a postgres function which automatically updates some value based on other value? for example, set completed to true when page field is certain value.
    j
    • 2
    • 1
  • Constraining select based on update RLS
    e

    Embm

    11/02/2022, 2:59 PM
    Say I have
    table_a
    with a
    select
    rls open to everyone, but on an editor page of my app I want to check if the user actually fulfills the necessary
    update
    rls (that is more constraining) before fetching the data. I can see many ways of doing this: - moving the
    update
    rls logic into a procedure that I can then separately call from my app's server to check before doing a select - manually keeping my app's
    select
    query's filter up to date with the
    update
    rls - ?? doing an empty
    update
    with a
    select
    modifier Is the last one a bad practice? Is there some other way of asking pg/sql to use the
    update
    rls for a specific
    select
    query without having to replicate the policie's logic?
    g
    • 2
    • 5
  • signInWithOAuth is not a function error.
    s

    sosapps

    11/02/2022, 5:00 PM
    I updated to v.2.0.5, still not working.
    g
    • 2
    • 14
  • Would it be possible to delay email verification?
    c

    Cheqo

    11/02/2022, 5:14 PM
    In the Auth Providers section, there is
    confirm email
    switch, when toggled users will have to verify their emails, if they don't they can't sign in. I want to delay the authentication to 24 or 48hours, I know that it's currently not possible, how something like this can be implemented? Should I make feature request?
    d
    • 2
    • 8
  • How to maintain record history
    j

    Jordan92

    11/02/2022, 6:46 PM
    Hey, I'm looking for a bit of advice for how to handle history of tables that have foreign keys where the foreign keys data can change. I'm working on a fitness app and have a table for every day you did a workout, which has a foreign key for a routine which has a foreign key for exercises. For example, a routine can be changed. Initially, you have a routine which has pull-ups and you then remove that and change it to deadlifts, but you have already completed a few workouts before you make this change. When you are viewing your history, I want it to be kept as it was when you completed that workout. If I completed the initial workout on Monday then change it on Wednesday and complete an updated workout when I review my workout history, I want it to have: "Monday: routine-1: pull-ups, Wednesday: routine-1: deadlifts" Is this possible, and if so, is there a good way to implement this?
    g
    • 2
    • 2
  • Updating user table
    d

    dev Joakim Pedersen

    11/02/2022, 7:06 PM
    I got a table that's is triggered by auth. just like the guide online on supabase docs. And now I've come to the part where I want the user to fill in other details to my public table. like address, email. a username etc. But I'm lost between the different ways to do so. Should I use upsert. insert, update ? I think it's upsert, but I want to make sure since I can't get any working atm 😂
    g
    • 2
    • 4
  • VerifyOtp() 401 error but verified user being created in Supabase without verification
    p

    pakkerr

    11/02/2022, 7:22 PM
    I'm noticing weird behaviour with my app with regards to the verifyOtp() function. STACK: Next.js React Hook Form (for accepting user input) USE CASE: I'm creating a sign-up wizard, where the user is prompted for their email, which then gets sent a verification code. I then take the user to a page where they enter the OTP received. Upon successfully verifiying their email with OTP, they should be directed to a "Complete Your Profile" page The code for this function is here:
    Copy code
    const sendVerificationCode = async (data) => {
            setLoading(true)
            setEmail(data.email)
            const { error } = await supabase.auth.signInWithOtp({
                email,
                shouldCreateUser: false
            })
            if (!error) {
                setLoading(false)
                router.push('/sign-up/with-email/verify-email')
            } else {
                setLoading(false)
                console.log(error)
            }
            
        }
    The email with the verification code gets sent successfully, but I notice that a verified user is created in supabase, before verifying the OTP. This is problem 1 and I am not sure what's going wrong. The second problem is a 401 error is returned when calling the verifyOtp function on the subsequent page. The code for this function is here:
    Copy code
    const [email] = useEmailSignUpStore((state) => [state.email], shallow);
    
        const verifyCode = async (formData) => {
            setErrorMSG(null)
            setLoading(true)
            const token = formData.otpInput
            const { error } = await supabase.auth.verifyOtp({ email, token, type: 'signup' }) 
            if (!error) {
                setLoading(false)
                router.push('/sign-up/with-email/complete-profile')
            } else {
                setLoading(false)
                console.log(error)
                setErrorMSG('Invalid Verification Code')
            }
    
        }
    g
    • 2
    • 6
  • ORM RLS Support
    j

    jkjr

    11/02/2022, 7:27 PM
    I believe I already know the answer, but are there any ORMs that can leverage Supabase's RLS (without having to create multiple instances of the ORM client with different credentials)?
    n
    • 2
    • 1
  • Getting a 500 error when deploying on vercel?
    l

    lewisd

    11/02/2022, 8:14 PM
    Hi guys, thought id try my app out on live but currently I am getting the following error:
    Copy code
    code:500
    error_id:"17246b26-b51a-4408-b5d6-fb2a0ee891be"
    msg:"Internal server error"
    This is calling
    https://pqxrgqvvtvjseejnwqvh.supabase.co/auth/v1/user
    Looking at the auth logs, the error says:
    "msg": "Unhandled server error: invalid claim: subject missing",
    Anyone ran into these problems before? I have `console.log`'d my supabase url and key and can confirm both are there, in the enviroment variables hosted on vercel.
    n
    • 2
    • 23
  • Hcaptcha + OTP
    r

    reed

    11/02/2022, 8:27 PM
    Should a user have to submit a captcha twice to login with an OTP (once to request the OTP via
    signup
    method, and once to verify the otp via
    verifyOtp
    method)?
    g
    m
    • 3
    • 5
  • Action on new Google OAuth registration
    n

    noahflk

    11/02/2022, 10:34 PM
    Whenever a new user registers I would like to send out an API request. How can I best do that? Ideally I would like to have a
    onSuccess
    callback on the
    supabaseClient.auth.signInWithOAuth
    function.
    g
    • 2
    • 1
  • Group or filter by hour in PostgREST
    k

    KTibow

    11/02/2022, 11:00 PM
    I'm using Supabase for a bot that keeps track of message times. As such, for my command that analyzes them to make a graph, I'll need to group/sort/filter them. Is that even possible with PostgREST or will I have to fetch all of them first? Would a view be appropriate for this?
    s
    • 2
    • 1
  • [Dart] How to copy a PostGrestFilterBuilder?
    c

    caseycrogers

    11/02/2022, 11:16 PM
    TLDR: how to I copy a
    PostGrestFilterBuidler
    object so I can get a second instance of it? I have a long function that slowly builds up a
    PostGrestFilterBuilder
    with a series of filters. Then, at the end, I want to run the query twice, once with one filter, and once with another, and return both results (I can't use an
    and
    because I'm using this to affect the ordering). I'm basically doing a convoluted
    order by some_column = some_value
    . I have to do it this way because AFAIK the supabase
    orderBy
    function only supports strict column names, not espressions Here's a shortened example of what I want:
    Copy code
    dart
    Stream<Foo> getFoos(PostGrestFilterBuilder builder) async* {
      var builderA = builder.copy().eq('some_col', 'some_value');
      yield* _paginated(builderA);
      var builderB = builder.copy().neq('some_col', 'some_value');
      yield* _paginated(builderB);
    }
    Alternatively, you guys could make the filter methods return a new object instead of mutating the existing one. Side effects suck, they're hard to reason about and work with. They're especially obnoxious here because the following (extremely common pattern) makes the linter yell at you for not awaiting a future:
    Copy code
    dart
    if (limit != null) {
      builder.limit(limit);
    }
    The following is much more explicit and doesn't make the linter mad:
    Copy code
    dart
    if (limit != null) {
      // If limit returned a new instance instead of side effecting:
      builder = builder.limit(limit);
    }
  • Newbie RLS question
    h

    Hege

    11/02/2022, 11:26 PM
    I'm working on a React app and I want to use RLS, but I'm stuck in how to actually make the request to supabase when the user is authenticated, here's what I'm trying: const {data, error} = await supabase.from("profile").select().eq("id",user.id) Where the "profile" table references auth.id on column "id" and I already have the user authenticated and its id on user.id But I get this error: permission denied for table profile I'm sure it's easy but I haven't found how to do it in the docs, Thanks!
    g
    • 2
    • 75
  • Can you change the url that shows up for Google Auth?
    j

    JustinT

    11/02/2022, 11:49 PM
    How can I change this link in this picture?
    g
    • 2
    • 2
  • host request header is not available
    b

    Blobby

    11/02/2022, 11:52 PM
    Error randomly started popping up. No idea why -
    Copy code
    Error: The "host" request header is not available
        at isSecureEnvironment (D:\code\gameface\node_modules\@supabase\auth-helpers-shared\dist\index.js:226:11)
        at Object.setItem (D:\code\gameface\node_modules\@supabase\auth-helpers-shared\dist\index.js:402:47)
        at D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\lib\helpers.js:89:19
        at Generator.next (<anonymous>)
        at D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\lib\helpers.js:31:71
        at new Promise (<anonymous>)
        at __awaiter (D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\lib\helpers.js:27:12)
        at setItemAsync (D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\lib\helpers.js:88:46)
        at SupabaseAuthClient._persistSession (D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\GoTrueClient.js:840:43)
        at SupabaseAuthClient.<anonymous> (D:\code\gameface\node_modules\@supabase\gotrue-js\dist\main\GoTrueClient.js:835:28)
    Help?
    d
    • 2
    • 10
  • Supabase queue processing
    d

    Dotjosh

    11/03/2022, 12:56 AM
    I'd like to have a queue in Supabase. I'm using PGBoss within postgres for the queue structure, but I have to run a separate process outside of supabase to process it. Are there any suggested patterns to replace this from all within supabase?
  • upload indicator for bucket uploads
    u

    ((()))

    11/03/2022, 1:16 AM
    how would one handle an upload indicator, are there any events I can listen for?
    j
    • 2
    • 1
  • Check if date is between two dates
    d

    Dies.Irae

    11/03/2022, 3:24 AM
    Can I use the supabase methods to check if a date is between two ranges? I'm trying to do an insert if Date.now is between a start_date and end_date
    j
    • 2
    • 16
  • More than 2 free projects?
    w

    whiskeywizard

    11/03/2022, 4:33 AM
    Hi, I like having a test and prod project for each app, and the test apps don't require the pro plan. If I upgrade a production project to the $25/mo, do I get additional free projects? Thanks.
    n
    d
    • 3
    • 6
1...585960...230Latest