https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Best approach to putting new rows into a review queue
    j

    jacobL

    10/15/2022, 8:43 PM
    Hey! I'm pretty new to doing database shenanigans and thought Supabase looked nice and easy to use. The site I'm building has posts that users can create. I need new posts to be sent to a review queue (admin UI I can make) where they can be checked by a human to make sure they aren't spam or malicious. Any ideas for doing something like this? Is this something that I can do with Supabase or will I need to use something else? Not sure if it helps but the site is made with Remix
    g
    t
    • 3
    • 4
  • Get user API returning HTTP 500?
    n

    Neki

    10/15/2022, 11:39 PM
    I'm trying to implement auth with providers, but when I make a request, I get an HTTP 500 response
    g
    • 2
    • 9
  • Error when trying to initialize the SB js client (expo react native)
    c

    czypnt

    10/16/2022, 12:45 AM
    Getting this error message when I try to initialize the client, any ideas?
    g
    • 2
    • 1
  • withPageAuth, user is always undefined
    u

    user8923

    10/16/2022, 1:37 AM
    What am I doing wrong here? Or is it a bug? The user variable is always undefined...
    Copy code
    ts
    // index.tsx
    
    import { User, withPageAuth } from "@supabase/auth-helpers-nextjs";
    
    type HomePageProps =
        {
            user: User;
        };
    
    export default function HomePage({ user }: HomePageProps)
    {
        return <div>Hello { user.email }</div>;
    }
    
    export const getServerSideProps = withPageAuth({ redirectTo: "/login" });
    g
    • 2
    • 2
  • withPageAuth redirectTo, how to go back to previous page after login?
    u

    user8923

    10/16/2022, 3:40 AM
    Copy code
    js
    export const getServerSideProps = withPageAuth({ redirectTo: ("/login") });
    After authentication in the /login page, I can't figure out how to route back to the previous page. I don't want to have to manually add a "referrer" query parameter in the redirectTo field, and I also want the ability to include any possible query params or anchors that existed in the previous page's URL. I can't use router.back() because apparently the redirection to the login page uses router.replace(), which doesn't write to browser history. Kinda stumped on this one!
  • [Solved] How can I do a three way join using a junction table?
    b

    bazooka_penguin

    10/16/2022, 3:46 AM
    The tables look like this Artwork(title, artist, id) Images(filepath, id, position) art_image(artid, imageid) I'm trying to do a three way join and select the artwork title, artist, and image with position 1. I looked at the documented examples but I was a little confused by the way nested selects work.
    t
    g
    • 3
    • 7
  • Twitter Login in React Native
    r

    rohanprasadofficial

    10/16/2022, 4:20 AM
    Hello All , I am trying Twitter login in an React native app and getting few errors. Not sure if it supports React Native or not ? If anyone has implemented that it would be great if they can share the example πŸ™‚ . Few errors i am getting are : One of them can be solved using react-native-async-storage but not sure about the other. Thanks
    a
    • 2
    • 4
  • Order by view count in JS library
    o

    oski啦

    10/16/2022, 6:12 AM
    Hey guys, I'm working on a book application, and want to be able to search books by filter + order i.e. view count. I have a table of all book views, so what I would want is a way to aggregate/count the views by book id. Any help would be appreciated. Thanks
    g
    j
    • 3
    • 14
  • UPSERT and autogenerated ID (primary key)
    j

    jkohlin

    10/16/2022, 8:13 AM
    I have an HTML form with 3 rows. I have 2 saved records in the table (user didn't fill in all) The next time the user logs in, he continues to fill out the form, which is pre filled with the previous 2 records from the db. - He edits one row - Fills in the last row, and submits. How can I: - save the new row, - update the edited one - ignore the unedited row ...without adding duplicates I tried this:
    Copy code
    await supabase
    .from('notes')
    .insert([
            {
                text: 'This is a test',
                user_id: '123',
                form_row: 1,
            },
            {
                text: 'This is another test',
                user_id: '123',
                form_row: 3,
            },
        ],
        { 
            upsert: true, 
            onConflict: 'id', 
            ignoreDuplicates: false 
        })
    .select()
    but get this error :
    null value in column "id" of relation "notes" violates not-null constraint
    id
    is auto increment Can I use UPSERT this way?
    g
    • 2
    • 2
  • Authenticating with username instead of e-mail? (installing self hosted)
    a

    Armitage

    10/16/2022, 10:02 AM
    I'm building an app that'll be used internally at my workplace. The users won't be using their email, phone number, etc. Rather, I'd like to provide them with a username and password so they can log in. They won't be registering their own accounts so I can generate them on my end and just provide credentials as required. Is there an efficient way to log in by providing a username field value instead of e-mail?
    g
    • 2
    • 1
  • Custom Edge Functions as an npm package
    a

    Abhinav_MV

    10/16/2022, 12:13 PM
    Hey Folks Lets say i create an edge function which does some function.... Is there a way i can deploy it as a package in npm/yarn so that other dev can just use this package to deploy it to there own supabase project ?? if this is possible could you point me to some documentation. And if it is not possible or should not be done could you tell me why ?? Thanks in advance, i am really new to supabase so sorry if this seems like a dumb question πŸ™‚
    • 1
    • 1
  • how to run a node js server on supabase
    w

    Warman

    10/16/2022, 1:16 PM
    I have a MERN stack application I would like to upload on supabase. Can it be done?
  • Supabase Auth UI
    r

    robf120

    10/16/2022, 1:32 PM
    I just installed the auth ui and page is rendering like thls with the default theme. Am i missing styling or something? πŸ˜…
    c
    s
    • 3
    • 12
  • [solved] Generating users in seed.sql
    c

    chrisgrabinski

    10/16/2022, 2:07 PM
    Hi folks, I would like to generate a handful of users + public profiles in my local dev environment but I can't get it to work. I found some docs and GitHub discussions around the topic but it didn't help me solve the problem. Ultimately, I created a user in the UI and logged in, to see which columns in the
    auth.users
    table will be filled. I then used this information in my
    seed.sql
    file. And while the users are actually showing up in the UI, when trying to log in (or sending a magic link from Studio), I am getting an
    Database error finding user
    /
    Failed to send magic link: Database error finding user
    error. Here's a snippet from my `seed.sql`:
    Copy code
    sql
    insert into auth.users (email, id, instance_id, aud, role, encrypted_password, invited_at, confirmation_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, created_at, updated_at, email_confirmed_at, email_change_confirm_status)
    values
      ('user-1@example.com', 'bd59c1b6-949a-44fb-b0e1-fac10f7367a1', '00000000-0000-0000-0000-000000000000', 'authenticated', 'authenticated', '$2a$10$jFOTJvSGDgj5ImgfH3DLeezIZY6HOayJvlE80lY0VdVfdY.zo3h7u', now(), now(), now(), '{"provider":"email","providers":["email"]}', '{}', now(), now(), now(), 0),
      ('user-2@example.com', 'bd59c1b6-949a-44fb-b0e1-fac10f7367a2', '00000000-0000-0000-0000-000000000000', 'authenticated', 'authenticated', '$2a$10$jFOTJvSGDgj5ImgfH3DLeezIZY6HOayJvlE80lY0VdVfdY.zo3h7u', now(), now(), now(), '{"provider":"email","providers":["email"]}', '{}', now(), now(), now(), 0);
    Am I missing something, or am I approaching this incorrectly?
    g
    o
    • 3
    • 4
  • deno function - smtp - works locally but fails remote
    v

    ven

    10/16/2022, 2:59 PM
    Hello, I have a deno function triggering a SendGrid email that works locally but fails on remote. this is the log of the error
    Copy code
    TimedOut: Connection timed out (os error 110)
        at async Object.connect (deno:ext/net/01_net.js:333:17)
        at async SmtpClient.connect (file:///src/main.ts:857:22)
        at async Server.<anonymous> (file:///src/main.ts:1173:5)
        at async Server.#respond (file:///src/main.ts:111:24)
    Severity
    ERROR
    Deployment version3
    Timestamp16 Oct, 2022 09:41
    Execution ID43ccbd3e-63eb-43bb-9ab6-06f58bc38ea0
    here is the key section of the function
    Copy code
    await smtp.connect({
            hostname: String(Deno.env.get('SENDGRID_SMTP_HOSTNAME')),
            port: Number(Deno.env.get('SENDGRID_SMTP_PORT')),
            username: String(Deno.env.get('SENDGRID_SMTP_USERNAME')),
            password: String(Deno.env.get('SENDGRID_SMTP_PASSWORD')),
        });
    
        try {
            await smtp.send({
                from: String(Deno.env.get('SENDGRID_SMTP_FROM')),
                to: payload.to,
                subject: payload.subject,
                content: payload.content,
            });
        } catch (error) {
            return new Response(error.message, { status: 500 });
        }
    
        await smtp.close();
    g
    • 2
    • 3
  • Create a user account with RLS
    g

    Gipson62

    10/16/2022, 3:38 PM
    Hello, I am new to Supabase and I would like to allow a user who has logged in to create an account based on his ID in "Users" auth. I have no idea how to do it using RLS, but I imagine it's possible. Can someone help me ? (I'm using Google trad cause I don't speak English, so I'm sorry if there is some mistake)
    • 1
    • 3
  • RPC Call Returns Zero Rows But Function Works as Expected
    j

    jon.m

    10/16/2022, 4:38 PM
    I'm using a function to return user profile data. When using the function in the SQL editor, it returns the proper information. But when using RPC, it doesn't work out, and the return data array is empty.
    Copy code
    SQL
    CREATE OR REPLACE FUNCTION fetch_user_details(usersid uuid)
    RETURNS table(
    user_detail_id bigint, 
    user_id uuid, 
    full_name text,
    user_email text,
    org_id bigint, 
    org_name text
    ) AS
    $$
    BEGIN 
       RETURN QUERY
       SELECT 
       u.id, 
       u.user_id,
       u.full_name,
       u.user_email,
       o.id,
       o.org_name
    
       FROM user_details u
       INNER JOIN org_details o
       ON u.org_id = o.id
       WHERE u.user_id = usersid;
       END
    $$
    language plpgsql;
    g
    • 2
    • 3
  • Trouble with refreshing auth tokens on the server
    d

    DanM

    10/16/2022, 6:10 PM
    I have working on implementing server based authorization for my web app using remix. I have been able to handle the sign in and supabase session storage fine. This will then allow me to pull the supabase session object out of the cookie in my loaders and query the database with the signed in user. My problem comes when I try to exchange the current session for a new one when the access token is expired. I'm passing the existing supabase session that I got from the signInWithPassword call on log in to auth.setSession(session). The problem is I always get an Invalid Refresh Token error. The documentation says that you are just supposed to send the refresh token to the setSession function but they types require the session object. If I try to use just the string I get an error stated that the Auth session is missing. Any ideas on they I'm getting the Invalid Refresh Token error? Someone has surely refreshed a token on the server before but I'm struggling to get it done. Any ideas would be a great help
    j
    • 2
    • 10
  • how to check if user exists only with Google OAuth?
    d

    Domcario

    10/16/2022, 6:38 PM
    im only giving users the option to sign in with google oauth (since the webapp im making is built on top of the google calendar api) once the new user has authenticated through google oauth, i want to bring them into a new user flow... how do i check if the user that just signed in is a new user?
  • [SOLVED] PgBouncer log warning
    n

    NanoBit

    10/17/2022, 3:30 AM
    Could you share Screenshots and example command to help debug
  • Securing API key using IP Address.
    d

    DanMossa

    10/16/2022, 8:21 PM
    I have a a Google API key I want to secure. One of the options to secure this with is
    ip
    . I have a postgres function that's calling API using HTTP and I'm putting the API key in that function. The IP address that's calling the HTTP req is
    23.90.20.110
    Will this ever change? Or can I reliably set the IP knowing it won't change?
  • Sveltekit auth helper update row (with RLS) fails without error
    a

    AlanK

    10/16/2022, 10:35 PM
    I have a +page.server.js default action with the following code:
    Copy code
    import { getSupabase } from '@supabase/auth-helpers-sveltekit';
    import { error, redirect } from '@sveltejs/kit';
    
    /** @type {import('./$types').Actions} */
    export const actions = {
        default: async (event) => {
            const { request } = event;
            const { session, supabaseClient } = await getSupabase(event);
            console.log('supabaseClient', supabaseClient);
            if (!session) {
                // the user is not signed in
                throw error(403, { message: 'Unauthorized' });
            }
            const formData = await request.formData();
            const { data: profileData, error: profileError } = supabaseClient
                .from('profile')
                .update({
                    first_name: formData.get('first_name'),
                    family_name: formData.get('family_name'),
                    phone: formData.get('phone'),
                    mobile: formData.get('mobile'),
                    mobile_reception: parseInt(formData.get('mobile_reception')),
                    rfs_survival_plan: formData.get('rfs_survival_plan')
                })
                .eq('id', session.user.id);
            console.log('profileData', profileData);
            console.log('profileError', profileError);
            if (profileError) {
                console.log('update error profileAboutMe:', profileError);
                throw error(400, profileError.message);
            }
            return {
                user: session.user,
                profileData
            };
        }
    };
    Both the session & supabaseClient seem fine, but after the update profileData, and profileError are both undefined. Am I missing something?
    j
    g
    • 3
    • 15
  • Auth error with Next.js example
    u

    0xRice

    10/17/2022, 1:27 AM
    I looked into line 80 of the error file, I think it has someting to do with
    subscription
    .
    Copy code
    // pages/login.tsx
    
    import { useSessionContext, useUser } from '@supabase/auth-helpers-react'
    
    const LoginPage = (): JSX.Element => {
      const { isLoading, session, error, supabaseClient } = useSessionContext()
      const user = useUser()
    
      if (isLoading || !user) {
        return <>Not login</>
      }
    
      return (
        <div className="flex h-screen">
          <h1>Test</h1>
        </div>
      )
    }
    
    export default LoginPage
    Copy code
    // _app.tsx
    
    import '../styles/globals.css'
    import type { AppProps } from 'next/app'
    import { SessionContextProvider } from '@supabase/auth-helpers-react'
    import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs'
    
    const App = ({ Component, pageProps }: AppProps) => {
      const [supabaseClient] = useState(() => createBrowserSupabaseClient())
    
      return (
        <SessionContextProvider
          supabaseClient={supabaseClient}
          initialSession={pageProps.initialSession}
        >
          <Component {...pageProps} />
        </SessionContextProvider>
      )
    }
    
    export default App
    • 1
    • 1
  • Full Text Search
    b

    BoogersLLC

    10/17/2022, 1:44 AM
    Referring to the Supabase Documentation: https://supabase.com/docs/guides/database/full-text-search#match-any-search-words I'm using the v1 Javascript client, and the following example is not true for me: "Notice how searching for big includes results with the word bigger (or biggest, etc)." i.e.
    textSearch
    only matches whole words for me (Big only matches Big). Wondering what I'm possibly missing here?
    j
    g
    • 3
    • 19
  • Delete row that has foreign key
    k

    kvnfo

    10/17/2022, 2:04 AM
    I have 3 tables Event Users Attending The attending table has foreign keys to users and events and connects user id to event (when attending) However some of these events need deleting and I can't do that until I manually delete entries from the attending table. What I want is to delete entry in the events table, which would then in turn delete every entry in the attending table that matche event.id
    g
    j
    • 3
    • 4
  • Getting a connection error on auth
    d

    death_wears_bunny_slippers

    10/17/2022, 2:20 AM
    I'm getting the following error. Any idea how to troubleshoot this?
  • Reset password question`
    d

    draco

    10/17/2022, 5:40 AM
    Assuming we are using a forgot password | reset password flow. Everything makes sense up until you get redirected to a url. When sending the new password using
    updateUser({password: 'some_password'})
    , where do you add in the
    access_token
    and other info from the url? I have seen previously that you can pass the access_token into the updateUser function but in v2 that is no longer the case. So what do you do when the user is trying to do a password reset and doesn't have a current session going?
    i
    • 2
    • 3
  • Problems with updated function
    k

    kresimirgalic

    10/17/2022, 7:41 AM
    I am getting the same error for the function i updated, this is the response: 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.sort_task(card_ids, new_board_column_id) function or the public.sort_task function with a single unnamed json or jsonb parameter in the schema cache" Can anyone help with it?
    g
    • 2
    • 1
  • Pausing is stuck
    m

    MDobs

    10/17/2022, 10:30 AM
    Pausing was stuck for over an hour in loading, and when I refresh the page the pausing status is gone
    g
    • 2
    • 1
  • what are the upcoming features that supabase is currently working on?
    t

    Thoth Trismegistus

    10/17/2022, 2:45 PM
    what are the upcoming features that supabase is working on?
1...464748...230Latest