https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • NetworkError
    p

    Philo van Kemenade

    10/17/2022, 3:32 PM
    when I run a saved SQL snippet to create new tables, I get the following error:
    An error has occured: NetworkError when attempting to fetch resource.
    any idea what might be causing this?
  • NextJS middleware helper sends user to unauthorized route after signInWithOTP() is fired.
    d

    Deed

    10/17/2022, 4:09 PM
    Hi, When I try to login with the signInWithOTP function and click on the magic link, the supabase/next middleware helper sends me to the unauthorized route even though I just authorized with the magic link. However, if I keep the cookies that were just stored then try to go to any protected routes or do signInWithOTP again, it works fine. Is there any way to work around this? Code: Middleware.ts
    Copy code
    export const middleware: NextMiddleware = withMiddlewareAuth({
      redirectTo: "/login",
      authGuard: {
        isPermitted: async (user): Promise<boolean> => {
          const res = await supabase.rpc("user_has_any_role", {
            user_id_: user.id,
          });
          return !!res.data;
        },
        redirectTo: "/unauthorized",
      },
    });
    
    // See "Matching Paths" below to learn more
    export const config = {
      matcher: ["/((?!api|_next|fonts|login|unauthorized|[\\w-]+\\.\\w+).*)"],
    };
    Login.tsx
    Copy code
    const handleLogin = async (email) => {
        try {
          setLoading(true);
          const { error } = await supabase.auth.signInWithOtp({
            email,
            options: { emailRedirectTo: "/shows" },
          });
          if (error) throw error;
          alert("Check your email for the login link!");
        } catch (error) {
          alert(error.error_description || error.message);
        } finally {
          setLoading(false);
        }
      };
  • New data is not showing
    d

    dev Joakim Pedersen

    10/17/2022, 4:18 PM
    I just added 13 new rows to my database of stores. it went from 166 stores to 179. it shows on supabase side, but on my website when I console.log the list of stores they do not show. is it not instant change? if so can I force it somehow? Thanks in advance
    g
    • 2
    • 2
  • Creating a random_username function with SQL Editor
    v

    Vik

    10/17/2022, 4:20 PM
    Hey there, sorry this might be a little basic of a question but I'm really new to Postgres and need some help. I'm in the process of creating a new random_username function that will return a username formatted like so:
    user1234567890
    . As far as creating this function I'm creating a new SQL snippet that I have structured as so:
    Copy code
    create or replace function random_username()
    returns username as $$
      declare
        
      begin
        
      end;
    $$ language plpgsql security definer;
    From here, I can't find much on how to future construct this function. Some docs I'm using are as follows: https://www.techonthenet.com/postgresql/functions/random.php I think the random() function would be perfect for this. How can I concat "user" + random numbers together in my function? Again, I apologize this is probably super basic. I'm just so new to this that it looks harder than it seems.
    k
    j
    • 3
    • 3
  • New supabase-kt
    j

    Jan Tennert

    10/17/2022, 6:44 PM
    Hey! As I didn't get a response on github I'll try it here. I made https://github.com/jan-tennert/supabase-kt providing complete APIs for Realtime, Functions, GoTrue, Postgrest etc. for Kotlin Multiplatform (JVM, Android, JS, Native soon). I'd transfer it to supabase-community if that's okay. (Can't do it myself obviously)
    s
    • 2
    • 41
  • Batch updating
    d

    dev Joakim Pedersen

    10/17/2022, 8:00 PM
    I was wondering what tools people use for batch updating their data here? My boss is looking for a no GEEK way of doing it. he got connected with excel but only got read not write. I bet this will work but interested to hear what people use 😄
  • local supabase cannot be configured for deep links?
    d

    dwma

    10/17/2022, 8:21 PM
    I can't find a way to make a development/local supabase be willing to send back a deep link for auth in an app. This is very simple in studio for cloud supabase, can be configured in the auth settings. Is there a sql command equivalent that can set the redirect URLs in the way that studio does it? This isn't a massive inconvenience since I can just build the URL I want after authing, but its definitely tedious.
    g
    • 2
    • 2
  • Hide a column?
    f

    Firlefranz

    10/17/2022, 8:37 PM
    I want to create a simple board where authenticated users can publish posts. I want the author of a post in my database (it is currently an author column in my posts table, referencing the built-in auth.users id). However, I want the posts to by anonymous, so no user should be able to retrieve the author from a post (maybe except the actual author). How can I restrict access for my users to that column? I can create a view with only all tha other columns, but when you know the original table name, it is still accessable. Afaik, I cannot apply separate RLS rules to views, or can I? Is there a different way to securely restrict access to a column?
    g
    • 2
    • 1
  • Is there any good TypeScript React Supabase v2 email Auth tutorial?
    i

    IVOBOT

    10/17/2022, 10:03 PM
    I'm asking, because I struggle a lot making my simple login with the new version of Supabase (I mean these async functions etc.; this behavior is strange), so I would like to have something to refer to. Thanks a lot in advance
    j
    m
    j
    • 4
    • 45
  • Run same function again after it completes
    t

    thestepafter

    10/17/2022, 11:15 PM
    Is it possible in PostgreSQL to call a function immediately after it completes? I tried with triggers but it caused a stack depth exceeded error. Basically I need a process to continuously run and process records if there are records available for processing.
    n
    g
    • 3
    • 20
  • Edge function using third party package with npm or yarn
    s

    StiffJobs

    10/18/2022, 1:45 AM
    I'm trying to move one of my frontend function to backend server, so I want to try it with something like firebase's cloud functions, but I didn't see any instructions about using third party package in edge function, and I want to know is it feasible?
    k
    • 2
    • 2
  • Nearest neighbour trigger function with PostGIS
    b

    Brams

    10/18/2022, 3:00 AM
    Hello fellow developers! Recently I've started a project using supabase to practice and learn React Native and some database concepts. Currently, I am trying to create a trigger function which looks at some geometry data and then sends a message to a client that is closest to the geometry point that is entered in a new row. I was wondering if there are any developers here who have some experience with PostGIS and might have a couple of minutes to teach me a thing or two.
  • Does Supabase support pgdash?
    t

    thestepafter

    10/18/2022, 3:13 AM
    Does anyone know if Supabase supports the use of pgdash (https://pgdash.io/)?
    • 1
    • 1
  • RLS policy 'in' not working
    s

    Shawn Conecone

    10/18/2022, 5:57 AM
    Hi, I'm trying to add an RLS policy to allow SELECT operation on a table. My table looks something like this room_table:
    Copy code
    id (Primary Key) | room_members(array of uid) | room_owner_uid (uid)
    where: - room_members is an array of the uid of authenticated users - room_owner_id is the uid of the owner. In the
    USING
    expression, I tried to do:
    uid() IN room_members
    but it doesn't work. A lot of example provided does not include this type of
    USING
    expression, so I have not had any luck getting the right way to do this. Anyone knows how to do this? Thanks!
    g
    • 2
    • 6
  • sudden jump of memory usage
    r

    ray

    10/18/2022, 7:01 AM
    hey guys! im actually bit concerned about the memory usage i saw yesterday, it was like 25MB ish, but now i checked it again, it's 55 MB now and, this is not the first time though, sometimes it decreases to 10 MB, and then went up back to 25 MB again i dont know whats going on in the background is it normal? is there something that i should be worry about? thanks ^^"
  • Simple tutorial for Google maps APi and supabase integration
    s

    Serj Hunt

    10/18/2022, 11:02 AM
    hey guys. newb here, I'm trying to display location cards on a map in my react app. i'd like to integrate Google maps API with supabase and get basic info like location name, google maps location description to display on my app. Any pointers, docs or videos would be really helpful!
  • Realtime not working for specific tables 🤔
    n

    NiklasPor

    10/18/2022, 11:46 AM
    Hey all, thanks for your time 🙂 We've got a lot of tables wired up via realtime, but for a few of them I'm not receiving any updates on the supabase instances which are hosted inside the cloud. It works flawless for all tables inside the locally hosted ones (CLI). We already tried: Disabling RLS, Resetting the replica settings (everything is turned on), Restarting the project This is how we're using it:
    Copy code
    ts
      supabase
        .channel('*')
        .on('postgres_changes', { event: '*', schema: '*' }, (payload) => console.log(payload))
        .subscribe();
    I don't even see the messages for the specific missing tables inside the WS messages tab in Chrome. Also this only happens for 2 tables out of 20 and only on the hosted supabase variants, which really leaves me guessing 😄 Any help is appreciated!
    g
    t
    • 3
    • 26
  • can't retrieve one to many relationship
    v

    valentin ッ

    10/18/2022, 1:16 PM
    Hi, I was looking at the Supabase tutorial(and the docs) on how to retrieve a one to many relationship, but what I did didn't work(response was null) I have a user table and a friends table, and I would like to get the name of every friend of a specific user, the thing is that the friends name has to be searched in the users table because I only store the added friend's uuid in the friends table. So I'd like to have an Object with the UUID aswell as the users name to be able to map a component with that data.
    g
    • 2
    • 14
  • Errors in Angular after updating to 2.0.0
    b

    Bizzare

    10/18/2022, 1:48 PM
    I'm receiving the errors found in the attached screenshot, after updating the javascript client to 2.0.0. I am using supabase with Angular 14 My 'supabase' service is quite basic: import { Injectable } from '@angular/core'; import { createClient, SupabaseClient } from '@supabase/supabase-js'; import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' }) export class SupabaseService { private supabase: SupabaseClient; constructor() { this.supabase = createClient(environment.supabaseURL, environment.supabaseKey); this.supabase.auth.onAuthStateChange((event, session) => { console.log('auth changed: ', event); console.log('auth changed session: ', session) }); } get session() { return this.supabase.auth.getSession() } signIn(email: string) { return this.supabase.auth.signInWithOtp({ email: email }); } signOut() { return this.supabase.auth.signOut(); } } I tried generating types with the CLI and using the Database type on the SupabaseClient generic constructor(e.g: SupabaseClient), but that did not work. Is there anything I'm missing to change with this SupabaseClient type, after the update?
    s
    u
    • 3
    • 7
  • Storage not scaling on higher plans
    s

    Sacha

    10/18/2022, 3:05 PM
    Hello there! I'm currently super low on most of my metrics on the usage of my DB, but the storage one is super restricted (only 8 GO?) and I can't find a way to scale that without x2 my CPU, which is something I don't need at all. How could I get that sorted? Thanks! I can't even see what are the storage upgrades in the plans btw.
    g
    • 2
    • 11
  • Integrating Full Text Search with supabase
    l

    Lukas V

    10/18/2022, 4:03 PM
    Hi, I have few questions regarding implementation of Supabase full text search, I was reading the docs here https://supabase.com/docs/guides/database/full-text-search#to_tsvector Currently I have custom react hook function:
    Copy code
    const getFullTextSearchIngredients = async (
      queryString: string | undefined
    ) => {
      let query = supabase
        .from<SupabaseIngredient>('ingredients')
        .select(
          '*',
          {
            count: 'exact'
          }
        )
        .order('popularity', { ascending: false })
        .limit(20);
    
      if (queryString) {
        query = query.textSearch('product_name', queryString, {
          type: 'phrase'
        });
      }
    
      const { data, count, error } = await query;
    
      if (error) {
        throw new Error(`${error.message}: ${error.details}`);
      }
    
      if (count === 0) {
        return null;
      }
      return data;
    };
    I pictured an example query, if you have a look "Chicken, broiler or fryes, breast, skinless..." should've been retrieved in both queries, but is only present in the first one. Now, I do realise that the ingredient name is very obscure and could be renamed, however as I was reading docs there were different functions mentioned such as:
    to_tsvector()
    to_tsquery()
    @@
    . I don't understand what they do, but can they be included in supabase javascript method
    .textSearch()
    to improve the search? Or is it just postgres limitations and I should simply rename the ingredients 😁
    g
    • 2
    • 1
  • Supabase apiauth 500 error on Vercel
    m

    MrPreet

    10/18/2022, 4:56 PM
    Supabase api/auth 500 error on Vercel https://github.com/supabase/supabase/issues/9402
    s
    j
    • 3
    • 6
  • 404 on update if rls enabled
    t

    Tomasz Szczuciński

    10/18/2022, 5:44 PM
    Hello, quick question from my side. Is it okay that supa is returning 404 status when user doesn't have rights to update row (rls blocks)? Sorry, I couldn't find info about this anywhere :/
    g
    • 2
    • 1
  • Logging in with signInWithOTP() in Next SSR reroutes me to the unauthed route
    d

    Deed

    10/18/2022, 6:11 PM
    Hi, When I log in with signInWithOTP(), I still get rerouted back to the unauthenticated route despite being authenticated from opening the magic login link. I can access pages just fine if I change the url my self. Heres my code for ssr authentication
    Copy code
    export const getServerSideProps: GetServerSideProps = withPageAuth({
      redirectTo: "/login",
      async getServerSideProps(ctx, supabase) {
        const {
          data: { user },
        } = await supabase.auth.getUser();
        const res = await supabase.rpc("user_has_any_role", {
          user_id_: user?.id,
        });
    
        return {
          redirect: !!res.data ? undefined : { destination: "/unauthorized" },
          props: {},
        };
      },
    });
    Heres the login code
    Copy code
    const handleLogin = async (email) => {
        try {
          setLoading(true);
          const { error } = await supabase.auth.signInWithOtp({
            email,
            options: { emailRedirectTo: "/" },
          });
          if (error) throw error;
          alert("Check your email for the login link!");
        } catch (error) {
          alert(error.error_description || error.message);
        } finally {
          setLoading(false);
        }
      };
    j
    • 2
    • 136
  • Require HCaptcha when adding to Supabase Database
    l

    logo

    10/18/2022, 6:41 PM
    Hey! Is there a way to force a HCaptcha when you add to the database? I only see an option for authentication.
    r
    • 2
    • 62
  • What is the maximum database size?
    r

    ralusek

    10/18/2022, 7:17 PM
    And is the database automatically partitioned as it grows?
    g
    • 2
    • 1
  • RLS - Restrict based on a token
    h

    HTMHell

    10/18/2022, 7:21 PM
    I have
    shopping_carts
    table, and unauthenticated users can create a cart. When creating a cart, I'll use a token which will be stored in the client. I want to be able to restrict access to carts based on the token, so only a user who knows it can select / update it. Any suggestions?
    g
    • 2
    • 2
  • Supabase JS help
    c

    Cazineer

    10/18/2022, 8:46 PM
    Hello, New Supabase user here. I'm having some real problems with the documentation - particularly around TypeScript. I've started working through the SvelteKit guide found here. https://supabase.com/docs/guides/with-sveltekit I immediately ran into a wall where TypeScript was having issues and it turned out the guide is for the 1.0 version and not 2.0. Methods have changed, which is fine. I'm now stuck because I can't find appropriate documentation on the
    error
    type
    AuthError
    . I've tried searching for this type with no luck. Why is the Supabase documentation so obscure? I don't mean to be rude but providing clear and concise documentation on types (objects) and their methods/properties is fairly standard in 2022. I'm basically stuck because the guides are dated and there does not seem to be updated documentation or any documentation for that matter that clearly states the properties and methods for simple things like the error object. Thanks!
    s
    • 2
    • 5
  • Supabase Storage In Local Development Not Returning Images
    d

    drewbie

    10/18/2022, 9:47 PM
    I am unable to view images from Supabase Storage while using local development. I am able to upload images to Supabase Storage locally, but when I try to access them from the url thats returned from getPublicUrl, I get a 404.
    Copy code
    {
      "statusCode": "404",
      "error": "Not found",
      "message": "The resource was not found"
    }
    I can also confirm that the images are in fact uploaded to the database, which I have to do by going to the Database tab in studio and changing the schema to storage since the Storage tab isn't there in local development Supabase. The buckets are good as far as RLS goes, everything works fine with the same set up in a hosted environment, its just with local development. I'm hoping to be able to view local images and that I am missing something obvious 🤷. Thanks
    g
    • 2
    • 15
  • Email verification redirecting to localhost
    c

    caseycrogers

    10/18/2022, 11:27 PM
    I'm following the flutter quickstart guide: https://supabase.com/docs/guides/with-flutter#setup-deep-links I had auth fully working, but then I tried to update my site URL and it all broke, so I thought I undid everything but it's still not working. Here's where I am now: My site URL is
    http://localhost:3000
    My additional redirect URL is
    io.supabase.castmeapp://login-callback/
    Here's the redirect URL I'm getting:
    https://magmdywarmnzoatbuesp.supabase.co/auth/v1/verify?<snipped>&type=signup&redirect_to=http://localhost:3000
    The account gets verified, but I get redirected to localhost rather than getting redirected to the login callback. Two questions: 1) What am I doing wrong, so that I can get things back into a working state? 2) How do I construct custom redirect URLs such that, if the user is on their phone, they get deep linked, but if the user is on their laptop (eg checked their email from a separate device) they go to my custom domain? Is there anything special about the format of the scheme? Can I use
    http/https
    as my scheme and construct an app link as my redirect URL? How is Supabase auth picking what link to redirect to? Is it doing a naive string match on
    login-callback
    for the host?
    o
    • 2
    • 7
1...474849...230Latest