https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • localhost dev setup failing during import
    k

    Kenneth J Hughes

    02/17/2023, 5:26 AM
    What would be causing
    import { createClient } from '@supabase/supabase-js'
    to fail with
    Uncaught SyntaxError: The requested module './../../../../cross-fetch/dist/node-ponyfill.js' does not provide an export named 'default' (at PostgrestBuilder.ts:1:8)
    in the browser console?
    s
    • 2
    • 12
  • Tried deleting a file from storage bucket but it remains...incorrect policy?
    v

    Vince

    02/17/2023, 5:46 AM
    Here is my snippet of code:
    Copy code
    const {data, error} = await supabase.storage
            .from("my-storage-bucket")
            .remove([original_file_name]);
    original_file_name
    is the file name in a DB table that matches the file name in the storage bucket at root. I think the syntax is correct but it can't get deleted. I'm don't have much familiarity with how RLS policies work and was hoping if someone could explain what I need to do to let each authenticated user to delete their own user-generated file that is uploaded in the storage bucket. I watched a YouTube video on it once but I can't seem to wrap my head around it. I have a policy screenshot attached that handles the DELETE function
    g
    • 2
    • 4
  • Auth security
    b

    bkyerv

    02/17/2023, 6:30 AM
    is this kind of code could be a good protection measure
    {!session ? <Auth /> : <Confidential />}
    ? I mean rendering component subject to presence of session. Is it possible that the piece of code on the client is changed to render the ` component without checking for the session?
    s
    • 2
    • 1
  • login in panel
    h

    Ho3einvb

    02/17/2023, 7:14 AM
    How to activate the login, when we enter the panel, we don't enter Supabase directly and it asks us for Gmail and password. Like the picture.
    s
    g
    • 3
    • 3
  • updating tables
    g

    Grimmjoww231

    02/17/2023, 9:14 AM
    good morning guys i found it easier to practice postgreSQL with the PGadmin tool.isthere a way i could migrate the database when its done to supabase?
    s
    • 2
    • 1
  • Upload cache on images ?
    d

    dev Joakim Pedersen

    02/17/2023, 10:42 AM
    I'm experiencing this horrible bug when uploading a file, where for android users. they can upload a image. delete it, post it. do whatever they like and no issue at all. smooth as butter. Whilst on apple devices the story is not the same. If they were to say upload an image. and then delete it since ah maybe they want to take a better picture. when uploading the next. they would get the first picture they uploaded in return. I reset the states and all, and do not think my issue is here but all cards are open. But rather maybe some cache related to os? or specific browser? or is it possibly how I take in the images? It acts as if there were some indexing issue. if this was an array, and after 5 attempts I finally get to see my second attempt. here is a copy of my html element
    <input onChange={(e) => handleThumbnail(e)} type="file" accept="image/*;capture=camera"  />
    Here is the handleThumbnail function:
    Copy code
    const handleThumbnail = async (e: React.ChangeEvent<HTMLInputElement>) => {
        const file = e.target.files?.[0];
        if (!file) return;
        try {
          const insertedImage = await image(file, true)
          setThumbnail(insertedImage)
        } catch (error: any) {
          setShowNotification(true)
          setNotification(error.message)
        }
      };
    The handleThumbnail function await image. which is a thing from a hook I made for this purpose. I have one hook for images that will get their background removed and one for normal images. since it's happening several places in my app. I will share the hook as a response to this post since I'm running out of characters. and also the function to delete an image below
    • 1
    • 4
  • Database structure for booking system
    e

    Evostance

    02/17/2023, 10:49 AM
    Just wonder if anyone has done this yet and what their approach was. Functionality wise, each "member" user has a booking system, and customers can book time out based on 5 minute slots. "members" can set open/close times etc, and customise this days, weeks, months etc in advance. So for example, maybe they only want to show available slots on a rolling 2 day in advance window. What approach would you take to structure this? 1 row per day, 1 row per week etc with the availability in a jsonb object? Would ideally keep this data for say 6 months historically
    j
    • 2
    • 13
  • Creating a table and using a json type field as a subcollection is it possible or feasible?
    g

    game2023

    02/17/2023, 12:32 PM
    Hello everyone, I'm new here, I worked with firebase and I was used to subcollections, I saw that supabase has a json field, could I use this json field as a subcollection? that is, if I have a user table and store 100,000 records in the json type logs field, would this be possible? i.e. working with the json field of my table as a subcollection ....
    g
    • 2
    • 2
  • Login with social providers and local supabase instance (Flutter)
    a

    avalanche

    02/17/2023, 12:49 PM
    I'm interested if it's possible to have social login with providers like google, facebook, etc completely on the local supabase instance. And if it is possible, is there any documentation how to setup configuration in config.toml for Flutter/Dart
    s
    m
    • 3
    • 6
  • Sharing functions and types between Supabase functions and frontend?
    e

    Eidur

    02/17/2023, 1:13 PM
    I'm a working on a Sveltekit + supabase project. I make heavy use of edge functions and I found myself rewriting a lot of the same utility functions for both. I'll appreciate any guides/examples of how to set up a mono repo like this: Packages: webapp (pnpm, sveltekit) supabase (/functions - deno) utility (can be imported both by sveltekit and deno)
    b
    l
    • 3
    • 22
  • Wonder if anyone can help - RLS - with other auth procvider
    j

    JacksGameDev

    02/17/2023, 1:27 PM
    Wonder if anyone can help - using NextAuth to do our authentication - but would like to use RLS - all the examples are based on using Supabase's own auth system. Is there any way to pass othe info with the query (from Prisma if it matters) so that the user_id or tenant_id is available to the RLS policy?
  • Can you join view?
    l

    Lukas V

    02/17/2023, 1:37 PM
    Hello, I have a jobs table where I store job listings, each listing has
    created_by
    column where I store
    uuid
    that links to
    users
    table. Currently I have this function to get jobs and join 2 tables:
    Copy code
    const getJobs = async () => {
      let { data, error, count } = await supabase
        .from('jobs')
        .select(`*, created_by(*)`, { count: 'exact' });
      if (error) {
        throw new Error(`${error.message}: ${error.details}`);
      }
      return data;
    };
    Everything works, but what if I decided to lock
    users
    table to protect some sensitive info. For that I created a view -
    public_users_info
    , where I store fields like avatar_url, username, full_name. However, it seems like I can't join this view as I would with the table? should I do something different?
    s
    • 2
    • 21
  • How to extend typescript definition in v2
    m

    Martin INDIE MAKERS

    02/17/2023, 1:39 PM
    i need to declare a var who come from supabase. it's called channel and in the query i get the user link to the channel like that
    Copy code
    typescript
        const channel: TYPEHERE = null
        const req = supabase
          .from('channel_users')
          .select(`
              id,
              channel_id,
              user_id (
                id,
                email,
                first_name,
                last_name
              ),
              created_at
            `)
            .single()
       channel = (await req).data
    The query return the right type but in all my function i dont know how to get the type so right now i do something like that, who feel very bad
    Copy code
    typescript
    interface ChannelUsers {
      user_id: Database['public']['Tables']['users']['Row']
    }
    
    const element: Database['public']['Tables']['channel_users']['Row'] & ChannelUsers = {} as any
    Then in my function i use
    typeof element
    to get the right type, but that seem a bit over engeneer. Plus the type returned is too wide.
    s
    a
    • 3
    • 50
  • NextJS Middleware for Auth
    j

    Jim

    02/17/2023, 1:46 PM
    Hey all just wondering, with next middleware, should I be concerned with auth calls for every route change? Could it be better to somehow cache the auth with cookies of some sort? https://github.com/supabase/auth-helpers/blob/main/examples/nextjs/middleware.ts In my middleware function I also query the database to test for the user role:
    Copy code
    js
    export async function getUserRole(userId: string, supabase: SupabaseClient) {
      const { data, error } = await supabase
        .from("user_roles")
        .select("role")
        .eq("id", userId);
      if (error) {
        throw error;
      }
      return data[0].role;
    }
    Probably better to not worry about it right?
  • Issues while hosting supabase
    h

    Hosenur

    02/17/2023, 1:59 PM
    I am self hosting supabase in digital ocean , but after running the compose command, all docker commands stop running , and some images turn to unhealthy
  • Nextjs13 and data fetching
    o

    olivercito

    02/17/2023, 2:38 PM
    I've just seen this supabase youtube tutorial (Fetching and Caching data in Next.js Async Server Components -

    https://www.youtube.com/watch?v=GniRj1jIhFw▾

    ) and I've a questiona about AUTH. In this tutorial it's used the supabase-js library for data fetching, but if wanted to add auth with auth-helpers, we should use it as serverComponent and browserComponet as indicated i supabase tutorial (https://supabase.com/docs/guides/auth/auth-helpers/nextjs-server-components) ALSO for fetching data, right? So if we use supabase auth in nextjs 13 server components, our createclient will be this 2: - import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs' - import { createClient } from '../utils/supabase-browser' for both authentication and data fetching, and DO NOT need to use supabase-js as indicated in the last youtube tutorial. Do you confirm?
    g
    s
    m
    • 4
    • 12
  • can I limit the size of rows or size in MB of a table?
    g

    game2023

    02/17/2023, 2:55 PM
    For example, I want my table to have a maximum of 100,000 rows and if it arrives, it starts rewriting (recording over other rows) is this possible to limit?
    g
    • 2
    • 2
  • CI/CD times with supabase-cli start are long
    t

    Thomas H

    02/17/2023, 3:23 PM
    Is there a way to decrease the amount of time it takes to pull the docker images pulled by
    supabase start
    ?
    docker image save
    is not the solution, save/load takes, combined, 6-7x times longer. Do anyone know of a different solution?
    s
    h
    • 3
    • 5
  • PGRST104 -Unexpected param or filter missing operator
    a

    ak4zh

    02/17/2023, 3:25 PM
    On a simple select I am getting following error:
    Copy code
    js
    existing = supabase.table('tenders').select('id').match({"tender_no": item['tender_no'], "state_id": STATE_ID}).execute()
    ERROR
    Copy code
    File "/usr/local/lib/python3.11/site-packages/postgrest/_sync/request_builder.py", line 64, in execute
        raise APIError(r.json()) from e
    postgrest.exceptions.APIError: {'code': 'PGRST104', 'details': 'Failed to parse [("state_id","Filters.EQ.5"),("tender_no","Filters.EQ.125485")]', 'hint': None, 'message': 'Unexpected param or filter missing operator'}
    g
    s
    j
    • 4
    • 21
  • Restrict edge function access to auth'd users?
    k

    Ken

    02/17/2023, 3:47 PM
    Hi There, How can I restrict edge function access to authorized users? I am using the edge functions to query an outside database for integration and now I am leaking all of my outside data as anyone with the anon key can grab data from that database. I am open to the idea that my design pattern is totally wrong. Is there a reference for restricting edge function auth or security?
    • 1
    • 2
  • Complete Server Side Auth
    j

    JumpingBack

    02/17/2023, 6:20 PM
    Instead of using supabase client side for auth is there a way to do this completely server sided not giving any api key's to the user client side. This is because we can pass on the info from the user to the
    action
    and then set the headers from there but is this a viable option maybe? is this slow?
    s
    d
    g
    • 4
    • 31
  • Auth from another subdomain
    c

    cufta22

    02/17/2023, 6:23 PM
    So I'm wondering if i can have one subdomain like account.test.com that will handle authentication for any other subdomain on *.test.com, I'm using Email, GitHub & GitLab from managed host if that helps
    g
    • 2
    • 3
  • Auto delete a row if a row in auth gets deleted
    n

    NeoPrint3D

    02/17/2023, 7:22 PM
    I am wondering if a user is deleted in auth if there is any way to delete associated rows that the user has created
    y
    • 2
    • 6
  • Facebook login not triggering AuthChangeEvent in Flutter
    a

    avalanche

    02/17/2023, 7:23 PM
    After calling signInWithOAuth(Provider.facebook) and getting back 'true', onAuthStateChange stream didn't trigger AuthChangeEvent.signedIn like it does when logging in with Google. How can I get user or session information if user was indeed successfully logged in?
  • RLS with 3rd-party client libs?
    u

    user8923

    02/17/2023, 7:32 PM
    Is it possible to use 3rd-party client libs to query the Supabase DB while applying row-level security? I'm thinking of node-postgres and postgres.js for instance. Digging around a bit I found something about having to set a "current_user_id" variable to the current logged-in user but I'm not too sure how to do that. Thank you
  • Is "new_email" and "email_change_sent_at" stored in the user object forever?
    y

    yayza_

    02/17/2023, 7:35 PM
    I'm working on my "profile" page and if a user updates their email I want to show them a notice that there was an email sent to their new email address to verify. I was going to use something like
    if "current time" (unix) - data.user.email_change_sent_at (converted to unix) < 86400 (24 hours), then show notice
    , but if the
    new_email
    or
    email_change_sent_at
    key is removed automatically in supabase after a certain time anyway then I can just check if that exists.
    g
    • 2
    • 11
  • private bucket rls policies not working
    j

    JoshTheNerd

    02/17/2023, 8:05 PM
    I created a private bucket where users can upload their resumes. This works great. Now I want them to be able to download their owns resumes. They are stored in a folder with their userId. I used this RLS template. But when I do
    Copy code
    js
          const test= await supabase.storage
            .from("user-resumes")
            .list("3d73b524-e959-470c-a6b3-b38e4e4d841a");
    from the supabase JS SDK or if I try to create a signedURL it returns:
    { data: [], error: null }
    if I use
    .list
    Copy code
    {
      data: null,
      error: StorageApiError: The resource was not found
          at C:\Users\joshu\Documents\projects\redacted\node_modules\@supabase\storage-js\dist\main\lib\fetch.js:20:20
          at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
        __isStorageError: true,
        status: 400
      }
    }
    if I try to create a signedURL
    g
    • 2
    • 23
  • CreateBrowserSupabaseClient vs useSupabaseClient NextJS hooks
    d

    DYELbrah

    02/17/2023, 8:19 PM
    Hello, I'm wondering if there's any issues if I decide to use createBrowserSupabaseClient everytime I need to fetch something from a function outside of a React component? As an example, I have my own custom useUser hook that basically fetches the user using Supabase and caches it using React Query. It looks like this:
    Copy code
    import { createBrowserSupabaseClient } from "@supabase/auth-helpers-nextjs";
    import { useQuery } from "@tanstack/react-query";
    import type { Database } from "../../../types/supabase-types";
    
    const getCurrentUser = async () => {
      const supabase = createBrowserSupabaseClient<Database>();
      const {
        data: { user },
        error,
      } = await supabase.auth.getUser();
      if (error || !user) {
        throw error;
      }
      return user;
    };
    
    const useUser = () =>
      useQuery({
        queryKey: ["activeUser"],
        queryFn: getCurrentUser,
        retry: false,
        staleTime: 1000 * 60 * 20, // 20
        refetchOnWindowFocus: false,
        refetchOnMount: false,
      });
    
    export default useUser;
    I noticed that if I want to use the useSupabaseClient() hook inside the getCurrentUser function (instead of createBrowserSupabaseClient), I can't do so because it can only be run inside a hook/component. I realize I could pass down the client through a parameter but that's not very clean. Are there any issues with using createBrowserSupabaseClient instead? I like my current implementation and haven't ran into any issues yet.
    a
    • 2
    • 23
  • What's happening today?
    n

    nateland

    02/17/2023, 9:06 PM
    Gotten this message at least 5 times today....
    s
    g
    • 3
    • 151
  • Code in guide throws error
    m

    misakss

    02/17/2023, 10:03 PM
    The for supabase-provider.jsx in the following guide throws errors, please update: https://supabase.com/docs/guides/auth/auth-helpers/nextjs-server-components
    s
    a
    • 3
    • 8
1...135136137...230Latest