https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Trying to use Auth-helpers to save data to a database secured with RLS policies
    a

    Amara

    03/04/2023, 4:50 PM
    I have a database secured with RLS so that authenticated users can only access their data, i am having trouble saving and retrieving data from the database even it says i am signed in, and have a user object
    n
    • 2
    • 7
  • User folder deletion from storage bucket via a trigger on user deletion not working
    t

    tinyjetpack

    03/04/2023, 5:17 PM
    I'm attempting to delete a user folder in a storage bucket when a user is deleted from the users table, but it's not working. I'm wondering if this could be an issue with the policy. Lmk, if you need more info..
    g
    • 2
    • 23
  • Internal SvelteKit fetch() makes session null
    j

    J3ltR

    03/04/2023, 5:31 PM
    I have an issue with
    getSession()
    from the
    @supabase/auth-helpers-sveltekit
    package. In my project, I have a
    layout.svelte
    where I access the supabase session as follows:
    Copy code
    ts
    <script lang="ts">
      ...
      import type { LayoutData } from './$types';
    
      export let data: LayoutData;
    
      let session = data.session;
    
      let userId = session?.user.user_metadata.provider_id;
      let userAvatar = session?.user.user_metadata.avatar_url;
      let userName = session?.user.user_metadata.full_name;
    </script>
    
    <div class=wrapper>
      <NavigationBar {userId} {userAvatar} {userName} />
      <slot />
    </div>
    This layout uses data from the `layout.ts`:
    Copy code
    ts
    export const load = (async ({ fetch, data, depends }) => {
      ...
      const supabase = createSupabaseLoadClient<Database>({
        ...
      });
    
      const {
        data: { session }
      } = await supabase.auth.getSession();
    
      return { supabase, session };
    }) satisfies LayoutLoad;
    This works fine with a normal page. However, whenever I have a page which makes an API call in a `page.ts`/`page.server.ts` to a
    server.ts
    in which I need a supabase session:
    Copy code
    ts
    export const GET = (async (event) => {
      const session = await event.locals.getSession();
      ...
    the session in the
    layout.svelte
    changes to
    null
    (which makes my navigation bar looks like the user is logged out). My
    hooks.server.ts
    looks like this:
    Copy code
    ts
    export const handle = (async ({event, resolve}) => {
      event.locals.supabase = createSupabaseServerClient({
        ...
      });
    
      event.locals.getSession = async () => {
        const {
          data: { session }
        } = await event.locals.supabase.auth.getSession();
        return session;
      };
      ...
    The
    hooks.server.ts
    ,
    layout.ts
    and
    server.ts
    code I used are from https://supabase.com/docs/guides/auth/auth-helpers/sveltekit. Is the other session changing to
    null
    intended behaviour? Any idea how I can solve this issue? Thank you!
    s
    j
    b
    • 4
    • 40
  • Create new user with confirm email, but still logging in before confirmation?
    m

    mikel

    03/04/2023, 6:38 PM
    I'm building a Next.js app and need help with user authentication using Supabase. When a new user signs up, I want to redirect them to an 'information' page to answer a few questions (Age, job, name, location, etc..), but this page can only be accessed if the user is logged in. The problem is that I still need the user to confirm their email, so turning off email confirmation isn't an option. How can I create new users with email confirmation on, but still allow them to log in before confirming their email? Any help or guidance would be appreciated. Thanks!
    s
    y
    b
    • 4
    • 6
  • Postgres function arguments missing array types from UI
    r

    robertn702

    03/04/2023, 8:55 PM
    When trying to create a postgres function that accepts an array argument (
    text[]
    ,
    int[]
    , etc), I noticed that there aren't any array types provided in the select box
    g
    • 2
    • 3
  • Any tutorial for self hosted Supabase Edge Functions ?
    s

    squallsama

    03/04/2023, 9:00 PM
    Right now I'm trying to figure out how to deploy or just start development edge functions for self hosted supabase. Are there any tutorials for it ?
    g
    • 2
    • 16
  • Help importing the google-auth-library into my edge function
    j

    jonah

    03/04/2023, 9:23 PM
    This whole esm.sh paradigm is very new to me. I cannot for the life of me figure out how to import the google-auth-library into my edge function. I tried importing it from esm.sh, but I’m getting the following error: “Relative import path “http” not prefixed with / or ./ or ../ and not in import map from “https://esm……”” Any help would be greatly appreciated!
    e
    • 2
    • 1
  • Deno type error on edge function: import path with ".ts" extension
    a

    ajv

    03/04/2023, 9:28 PM
    Hi all, has anyone else received this error? I've tried using a .js extension instead and get a "cannot find module" error.
    m
    • 2
    • 1
  • Failed to send magic link: duplicate key value violates unique constraint "users_email_partial_key"
    n

    nateland

    03/04/2023, 10:10 PM
    Why does this happen?
    g
    • 2
    • 44
  • Reset Keys
    g

    gerry

    03/04/2023, 11:46 PM
    Is it possible to reset the the postgres password, the supabase service key, and the JWT?
    g
    • 2
    • 1
  • twitter auth?
    a

    alana

    03/04/2023, 11:52 PM
    following this guide for auth via twitter and get this page on the twitter dev portal that i don't qualify for access - is there any way around this?? https://supabase.com/docs/guides/auth/social-login/auth-twitter
  • Selfhosted problems
    c

    Colors

    03/05/2023, 1:01 AM
    I followed the guide on the docs to set up superbase selfhosted. Currently I acces the management panel over :3000(I currently don't know how this can be secured, I see a login page for a second but then it redirects me). I cant invite any new users to the project(
    Failed to invite user: User not allowed
    ) or create new buckets(
    new row violates row-level security policy for table "buckets"
    ). Also I can't set up auth providers(I only can set up policies). When I look at the broser console I see this error spammed in the console:
    _app-9045f33443b356a2.js:1          GET http://<MyServerIP>:3000/api/profile/permissions 404 (Not Found)
    o
    g
    • 3
    • 10
  • Cannot read properties of undefined (reading onAuthStateChange) in AuthProvider
    a

    alexanderwford

    03/05/2023, 1:13 AM
    Hi team, I'm trying to implement auth using an AuthProvider component and I'm getting the error message "TypeError: Cannot read properties of undefined (reading 'onAuthStateChange')" In the server console I'm getting the error "Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead." I've followed the guide found here: https://www.misha.wtf/blog/supabase-auth-next-13 I'm beating my head on the wall, I have no idea how to go about debugging his issue. Can anybody help?
    b
    • 2
    • 5
  • GraphQl Filters
    r

    rlee128

    03/05/2023, 1:41 AM
    I see on https://supabase.github.io/pg_graphql/api/#filtering there are filters for ilike and like and startwith but I don't see them when using Graphql as an option. Tried to usint the GraphQL Playground and also the built in one added in the Supabase console.
  • How can I determine what is a folder and what isnt?
    s

    salzar

    03/05/2023, 2:31 AM
    Hi, im currently trying to use this code to determine whether or not the current path is a folder or a file. Long story short, it doesnt work. How can I determine the difference between a file and a folder? I know folders dont ACTUALLY exist on supabase storage and its just a placeholder file, but I cant determine how to figure that out programmatically
    Copy code
    const handleClick = (fileData:string) => {
          setChecked((prevState) => !prevState);
          const extension = fileData.split('.').pop()?.toLowerCase();
          if (extension) {
            console.log(extension)
            if (!checked) {
              addCheckedFile(props.fileData);
            } else {
              removeCheckedFile(props.fileData);
            }
          }
        };
    g
    • 2
    • 24
  • Auth-Helpers sveltekit project won't build because session is null in createSupabaseLoadClient.
    a

    AlanK

    03/05/2023, 4:17 AM
    I have just upgraded my project to the latest sveltekit, supabase js and supabase/auth-helpers-sveltekit. I followed the documentation here (https://supabase.com/docs/guides/auth/auth-helpers/sveltekit#client-side-data-fetching-with-rls) to upgrade from 0.9 to 0.9. My project won't build because of the createSupabaseLoadClient function in the root +layout.ts file.
    Copy code
    import { invalidate } from '$app/navigation';
    import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public';
    import { createSupabaseLoadClient } from '@supabase/auth-helpers-sveltekit';
    import type { LayoutLoad } from './$types';
    import type { Database } from '$lib/db.types';
    
    export const load: LayoutLoad = async ({ fetch, data, depends }) => {
        depends('supabase:auth');
    
        const supabase = createSupabaseLoadClient<Database>({
            supabaseUrl: PUBLIC_SUPABASE_URL,
            supabaseKey: PUBLIC_SUPABASE_ANON_KEY,
            event: { fetch },
            serverSession: data.session,
            onAuthStateChange() {
                invalidate('supabase:auth');
            }
        });
    
        const {
            data: { session }
        } = await supabase.auth.getSession();
    
        return { supabase, session };
    };
    The buils fails with a
    Copy code
    TypeError Cannot read properties of null (reading 'session')
    pointing to
    Copy code
    serverSession: data.session
    Have I missed something?
    s
    • 2
    • 5
  • Typescript Error in realtime-js > RealtimeChannel.ts
    t

    TheWeakNinja

    03/05/2023, 5:14 AM
    Hi. Wrote these lines of code here (in a useEffect [Next 13]) and then the issue in the image attached popped up. The file with the TS error is in node_modules > @ supabase > realtime-js > src > RealtimeChannel.ts. How can I fix it?
    Copy code
    // Subscribe to realtime updates
            const messagesSubscription = supabase
                .channel(`room:${room_id}`)
                .on("postgres_changes", { event: "INSERT", schema: "public", table: "messages" }, (payload) => {
                    console.log("Received realtime update:", payload);
                    // Update list of messages
                    // Ignore TS error from line below because payload isn't typed correctly... ?
                    // @ts-ignore
                    setMessages((messages) => [...messages, payload.new]);
                    // Scroll to bottom
                    document.getElementById("scroll-to")!.scrollIntoView({ behavior: "smooth" });
                })
                .subscribe();
    I am also very new to TypeScript and Supabase both so if this is a commonly asked question, I apologize!
    g
    • 2
    • 3
  • How do I keep making requests to Google APIs using provider_token in session?
    a

    atgctg

    03/05/2023, 10:36 AM
    I'm querying Google APIs from my next.js app and I'm using the
    provider_token
    field from the session for the
    googleapis
    auth.
    Copy code
    ts
      const client = new google.auth.OAuth2()
      client.setCredentials({
        access_token: session.provider_token,
      })
    Problem is that after a while the
    provider_token
    field will be set to
    null
    . How do I prevent that from happening?
    s
    • 2
    • 1
  • NextJS Auth runtime error
    c

    chrtravels

    03/05/2023, 12:30 PM
    Hello all, I decided to go a different route with the login and doing the NextJS login tutorial: note: this uses @supabase/auth-helpers-react https://supabase.com/docs/guides/getting-started/tutorials/with-nextjs I had it working when using it in a modal but decided have it as it's own component and if the session doesn't exist, then load the login component. Otherwise load "/". I have a Layout component that I wrap Because of that I am doing the session check and Auth component load, right inside the context provider in the App component. Hope that's ok. It does load but when I submit my login details I get a popup Runtime Error: TypeError: Cannot read properties of undefined (reading 'signInWithPassword') From the _app.js:
    Copy code
    import Layout from '@/components/layout/Layout';
    import '@/styles/globals.css'
    import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs'
    import { Auth, ThemeSupa } from '@supabase/auth-ui-react'
    import { SessionContextProvider, useSession, useSupabaseClient  } from '@supabase/auth-helpers-react'
    import { useState } from 'react'
    // import UserProvider from '../context/userContext'
    
    
    export default function App({ Component, pageProps }) {
      const [supabase] = useState(() => createBrowserSupabaseClient())
      const session = useSession()
      const supabaseAuthClient= useSupabaseClient()
    
      return (
        <SessionContextProvider supabaseClient={supabase} initialSession={pageProps.initialSession}>
            {!session ? (
              <Auth supabaseClient={supabaseAuthClient} appearance={{ theme: ThemeSupa }} />
            ) : (
              <Layout>
                <Component {...pageProps} />
              </Layout>
            )}
        </SessionContextProvider>
      )
    Any assistance is appreciated. This Supabase auth has been a three day nightmare and hoping to get this sorted. If I get the login working, I think I can then access my user throughout the rest of the site.
  • authenticated users can't update my public table but anon can.
    m

    mattbcool

    03/05/2023, 12:37 PM
    I've tried creating a few policies to correct but currently blocked. Using magic link login. Welcome any suggestions. 🙂
    s
    g
    • 3
    • 8
  • Server side js functions
    t

    tommyb10

    03/05/2023, 12:49 PM
    What would be the best way to go about creating/deploying server side functions (e.g. external api calls, routine emails…)? Edge functions are unnecessary as they don’t need to be edge based, and not being able to self-host Deno isn’t what I’m after. Essentially looking to setup another docker container which contains supabase-js functions that can be triggered by a api call to a /function/:name endpoint. Any suggestions?
    • 1
    • 1
  • Combining `in` and `or` , with joined table
    a

    Amr

    03/05/2023, 1:02 PM
    Hi, I'm having trouble executing this query:
    Copy code
    js
    supabase
      .from('reservations')
      .select(`*,
        departure_trip:trips!reservations_departure_trip_fkey(*, repeating_trip:repeating_trips!trips_repeating_trip_fkey(*)),
    
        return_trip:trips!reservations_return_trip_fkey(*, repeating_trip:repeating_trips!trips_repeating_trip_fkey(*)),
    
        room_details:hotel_prices!reservations_room_details_fkey(*, hotel:hotels!hotel_prices_hotel_fkey(*),room:hotel_rooms!hotel_prices_room_fkey(*))`,
          { count: 'exact' })
      .or(`departure_trip.id.in.${trimmedTripsIdsString}, return_trip.id.in.${trimmedTripsIdsString}`,
          { foreignTable: 'trips' })
    I have an array of trip IDs , say
    const trimmedTripsIdsString = '(1, 2, 3)'
    I want to get all reservations that either subscribed to a
    departure_trip
    with an
    ID
    within that array, or a
    return_trip
    with an
    ID
    within that array. But that query returns
    null
    !
    g
    • 2
    • 56
  • How to get the currently logged in user profile
    c

    chrtravels

    03/05/2023, 1:35 PM
    Howdy! Wondering how to get the profile for the current session user. I did get the user with useUser() but that is just the auth.user and doesn't have any of the profile information. Supabase doesn't seem to let you use 'where', as below. Basically trying to grab just the profile that matches the user.id with the profile.id, rather that take up bandwidth returning the entire profiles table and sorting it out on the client side. Obviously not a good option. ;-p
    Copy code
    export async function getSessionProfile(userId) {
      let { data: profiles, error } = await supabase
      .from('profiles')
      .select('*')
      .where(profiles.id === userId);
    
      return profiles;
    }
    b
    g
    • 3
    • 7
  • Invalid hook call. Hooks can only be called inside of the body of a function component.
    s

    salzar

    03/05/2023, 2:40 PM
    Hi, I'm getting this error and I have no idea why, I've tried changing my code many times to make it work. Im basically importing my function components into my menu bar and trying to run it from there. How can I get that function to run on click? thanks, for any help in advance
    c
    b
    • 3
    • 9
  • Auth in local development
    y

    yngwi

    03/05/2023, 2:44 PM
    Hi, I wonder how to deal with Auth in local development. I have tried out the official "Auth/User management" tutorial and so far everything works as expected when I use the hosted Supabase environment, although the site url is set to localhost:3000. So, my question is this: I wonder, how I would do this if I have a published website, as the local development cannot send magic links and other emails (for example). What is the workflow to locally develop an already published web app based on Supabase that relies on magic links for sign in?
    s
    • 2
    • 2
  • [Server side] Setting a session to the supabase client doesn't work
    j

    joaquimley

    03/05/2023, 3:28 PM
    Hello everyone. I'm having trouble creating a "user scoped"
    supabase
    client, this is running on an express (NestJS) app. I'm instantiating it as usual:
    Copy code
    typescript
    import { createClient, SupabaseClient } from '@supabase/supabase-js';
    
    (....)
    
    const client = createClient(SupabaseConfig.url(), SupabaseConfig.anonKey());
    And setting the session like so:
    Copy code
    typescript
    const { data, error } = await client.auth.setSession({
      access_token,
      refresh_token,
    });
    If I
    console.log()
    the
    data
    property (after checking if
    error
    is null) it does return a session object including the user info but (and it even refreshes the tokens) but, If I try to request any data or query any data it just throws an auth error:
    Copy code
    typescript
    const user = await client.auth.getUser()
    Reading the documentation, it seems like this is the proper way to attach a session to a
    supabase
    client, so I don't really get what's happening. Thanks in advance.
    g
    j
    • 3
    • 6
  • Next13 and Supabase - insert() and get data
    d

    darkej

    03/05/2023, 3:48 PM
    I am struggle since some time with Supabase and Next13js (app folder). I have a page when I get all data from my table. Route = `/eggs/get`:
    Copy code
    js
    import supabase from "@/utils/supabase";
    
    export const revalidate = 0;
    
    async function getEggs() {
        const {data, error} = await supabase.from("eggs").select().order("created_at");
        if (error) console.error(error);
        return data;
    }
    
    export default async function Home() {
        const eggs = await getEggs();
        return (
        // render eggs
        );
    }
    There is a second page to get data from user and insert it into supabase:
    Copy code
    jsx
    "use client";
    import {useState} from "react";
    import supabase from "@/utils/supabase";
    import Link from "next/link";
    import {useRouter} from "next/navigation";
    
    export default function Page() {
        const [eggName, setEggName] = useState("");
    
        const router = useRouter();
    
        const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
            setEggName(e.target.value);
        };
    
        const handleOnClick = async () => {
            const {data: egg, error} = await supabase.from("eggs").insert({egg_name: eggName});
            if (error) console.error(error);
            router.push("/eggs/get");
        };
    
        return (
                <div>
                    <input
                        type="text"
                        className="w-[10rem] py-3 px-4 block border border-gray-200 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500"
                        onChange={handleOnChange}
                    />
                <button onClick={handleOnClick}>submit</button>
            </div>
        );
    }
    When user push button: 1. Insert new record into database 2. Redirect to
    /eggs/get
    Now sometimes it’s get fresh data and I am able to see new record but somtimes not - its not rendered. What is the best approach in Next13js to handle data insertion and immediatly see the changes ?
  • is there any way to integrate supabase with wallet connect or any custom providers for a web3 applic
    n

    NeoPrint3D

    03/05/2023, 4:19 PM
    My team and I are using supabase for production and is wondering if we could use it in tandem with wallet connect.
    v
    • 2
    • 1
  • Service Role Key, Project URL hardcoded in DB Function - Alternatives?
    y

    yngwi

    03/05/2023, 4:21 PM
    Hi, I'm currently doing the React User Management App Tutorial and in the [Storage Management](https://supabase.com/docs/guides/getting-started/tutorials/with-react#storage-management) section the code shows the hardcoded project url and service role key. Is there a way without hardcoding these into the db? This way I cannot use the migration from the local environment on the server as the values are different. Also, of course, it would be not a good idea to commit this migration to a Git repo. Some time there has already been another thread on this topic, although unanswered: https://discord.com/channels/839993398554656828/1079082083412095046 Pointers to alternatives are very welcome.
    g
    s
    • 3
    • 9
  • I can't add (from my application) or invite(from the dashboard) new users to my users table.
    s

    samuel83

    03/05/2023, 4:38 PM
    I am getting an error trying to invite new users to my users table: This is the error:
    Failed to invite user: failed to make invite request: Database error finding user
    Does anyone have any idea why this is happening?
    g
    s
    • 3
    • 12
1...154155156...230Latest