https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • How would I log in a user on NodeJs backend?
    w

    Wamy

    03/11/2023, 9:48 PM
    I tried this (https://supabase.com/docs/guides/functions/auth) but it doesn't work when trying to do it in nodejs and exporting the supabase client so I can use it in a function. Here is some code so you can see what I mean.
    Copy code
    js
    const { data, error } = await.userSupabase.auth.signIn({
        email: email,
        password: password,
    })
    console.log(error)
    console.log(data)
    This code returns nothing when run using the normal createClient using my service_key or my anon key. When I try and use the functions code,
    req
    is not defined because you have to use it in the deno server which I cannot in this case. Is there anyway to verify a user's credentials on the server? Its using basic auth to login so I have no jwt or anything like that.
    g
    • 2
    • 19
  • Can't invite new users to my project.
    s

    samuel83

    03/11/2023, 10:16 PM
    This has been happening to me several times and I can't really figure out what is going on here. Anytime I run Prisma db migrate reset, I get an issue with the auth.user table which doesn't allow me to invite new users. Has this happened to anyone before? What can I do to reset the auth.user table to work again when this happens? I am getting this error:
    g
    n
    • 3
    • 6
  • How do I get started with views?
    y

    yarbo

    03/11/2023, 10:16 PM
    Hi all, Im a big fan of Supabase so far 🙂 I’ve come across the term “views” in a few places, but don’t see any documentation on how to actually get started with them? Does someone have a click-by-click guide to creating a view and making it available via an API endpoint? I’ve also seen some documentation saying that views bypass Row Level Security settings in certain versions of Postgres or something. How would I need to handle that? Thanks!
    g
    • 2
    • 5
  • How to deploy all edge-functions
    j

    jarnold

    03/11/2023, 10:30 PM
    Is this possible? Would like to avoid having a deploy line for each function in my deployment scripts if possible Referring to https://supabase.com/docs/guides/functions/cicd-workflow
    - run: supabase functions deploy your-function-name --project-ref $PROJECT_ID
    g
    • 2
    • 2
  • Querying JSON Data
    a

    A-PRYME

    03/12/2023, 12:43 AM
    Hello everyone, can someone please tell me what is wrong with my code here?
    users
    is the name of the table, and
    address
    is a
    jsonb
    column.
    g
    • 2
    • 4
  • Support for Middle East Regions
    s

    SomGG

    03/12/2023, 1:18 AM
    Hey everyone, When I create a new project inside Supabase, I don’t see my region. Will choosing a different region affect my project in any way? And where should we expect support for other regions such as Middle Eastern countries?
    l
    • 2
    • 1
  • Google Auth User Cap
    r

    rattlesnake

    03/12/2023, 1:20 AM
    Hi all. It seems that apps using Google login will be capped at 100 users. https://support.google.com/cloud/answer/9110914 Does this affect Supabase auth as well? My project doesn’t access any sensitive or restricted user data. Thanks!
    s
    e
    • 3
    • 10
  • Error with npx supabase db diff
    s

    Stewball32

    03/12/2023, 2:43 AM
    npx supabase db diff
    keeps resulting in this error. I'm completely in the dark as to what's going on and why it's not working.
  • Issue implementing the openai edge function example
    j

    jonah

    03/12/2023, 6:42 AM
    I followed the openai edge function example perfectly, but I am seeing this error when I try running my edge function locally with the --debug argument:
    Copy code
    DEBUG Specifier "https://esm.sh/v111/openai@3.1.0/esnext/openai.js" was not mapped in import map.
    DEBUG Specifier "https://esm.sh/v111/form-data@4.0.0/esnext/form-data.js" was not mapped in import map.
    DEBUG Specifier "https://esm.sh/v111/axios@0.26.1/esnext/axios.js" was not mapped in import map.
    DEBUG Specifier "https://esm.sh/v111/node_process.js" was not mapped in import map.
    DEBUG Specifier "https://esm.sh/v111/node_events.js" was not mapped in import map.
    worker thread panicked ReferenceError: window is not defined
        at https://esm.sh/v111/form-data@4.0.0/esnext/form-data.js:24:59
        at https://esm.sh/v111/form-data@4.0.0/esnext/form-data.js:6:27
        at https://esm.sh/v111/form-data@4.0.0/esnext/form-data.js:32:11
    I don't know how to define the window for that form-data module. Can anyone help? I tried defining the window in my serve function but that didn't work.
    s
    m
    • 3
    • 2
  • implementing rls issue
    m

    mct.dev

    03/12/2023, 7:14 AM
    I have a table for companies and another table for employees i need to implement a rls so that only admin user who is an employee of that company can update the company info and insert new user and employee also can update delete employee .. how to achieve that ?
    g
    • 2
    • 1
  • storage is not full
    d

    Dean1

    03/12/2023, 8:31 AM
    I've been suffering for several days now, I can't make the storage fill up, help.
    g
    • 2
    • 30
  • Batch upload in RPC
    s

    STILLWATER;

    03/12/2023, 11:59 AM
    How do I batch upload with array of json in rpc? My current function:
    Copy code
    sql
    CREATE OR REPLACE FUNCTION upload_contacts(contacts json[]) RETURNS VOID AS $$
    BEGIN
    
      INSERT INTO "Contact" (user_id, phonenumber)
      SELECT (d->>'user_id')::uuid, d->>'phonenumber'::character varying
      FROM (SELECT json_array_elements($1::json) as d) tmp
      ON CONFLICT (user_id, phonenumber) DO NOTHING;
    
      RETURN;
    END;
    $$ LANGUAGE plpgsql;
    • 1
    • 1
  • Component Props Typescript Best Way?
    r

    Razoth

    03/12/2023, 12:09 PM
    Hello, i am very new to Typescript and was wondering if this is the correct way to pass supabase query data props from Nextjs Page to Component. Inside the page file VSCode Auto Generated this:
    Copy code
    js
    export async function getStaticProps(context: {
      params: { id: number };
    }): Promise<{
      props: {
        quote: {
          created_at: string;
          id: number;
          network: string | null;
          old_id: number;
          rows: import("../../types/supabase").Json;
          score: number | null;
          timestamp: string | null;
        };
      };
    }> {
      const id = context.params.id;
      const { data, error } = await supabase
        .from("quotes")
        .select("*")
        .eq("id", id)
        .maybeSingle();
      if (error) {
        console.log(error);
      }
      return {
        // Passed to the page component as props
        props: { quote: data! },
      };
    }
    inside the component i did this:
    Copy code
    js
    
    type prop = {
      quote: data;
    };
    
    type data = {
      id: string;
      created_at: Date;
      score: number;
      network: string;
      timestamp: Date;
      rows: [];
    };
    
    type rows = {
      row: number;
      content: string;
    };
    
    export default function QuoteCard({ quote }: prop).....
    is this correct?
    • 1
    • 1
  • Sync Google Sheet with Supabase
    s

    ShareOne

    03/12/2023, 12:38 PM
    Hi everyone. I would like to sync my google sheet with Supabase table in such a way that any update made on google sheet will reflect in my Supabase table. I need this because the platform I am using to scrap websites can only scrape to google sheet (automatically). And I am using Supabase to build an app in Flutterflow. Is there any video or tutorial you can recommend for me?
    t
    n
    • 3
    • 5
  • timestamps off by an hour after daylight savings
    a

    Aaron8646

    03/12/2023, 3:52 PM
    I left my db timezone untouched, as per the docs recommendations. But now when i submit something as 3pm, the UTC timestamp it gets converted to corresponds to 4pm. yesterday it worked fine
    • 1
    • 2
  • how can i link a file that goes into storage to a row of data in the database?
    d

    Dean1

    03/12/2023, 3:53 PM
    .
    g
    • 2
    • 5
  • Google Authentication Callback URL (Swift - IOS App)
    v

    Vishwanth22

    03/12/2023, 4:38 PM
    Hi! I just started learning Supabase and tried implementing it in swift. I am able to get user emails to show up in Authentication page however, I am not sure on how to model the site url and callback url such that I can get a fully successful authentication to get the session info. Currently in my implementation, upon pressing a login button, the users goes through a google authentication page, then it gets redirected to the Site URL (localhost) which gives an error. I have tried the localhost (https://localhost:3000 and https://localhost:3000/auth/v1/callback) but kept getting an error stating that the page could not be opened as it cannot connect to the server. Any help would be appreciated regarding this issue. Thank you!
    l
    t
    • 3
    • 26
  • How would I generate a random, unique, alphanumeric string that's 16 characters long as a primarykey
    s

    Sniped137

    03/12/2023, 4:44 PM
    As title suggests how would i generate a random unique string of alphanumeric characters that has the length of 16 characters, as the primary key in a table. For example for a blog posts id, or is there a better way to do it?
    n
    e
    j
    • 4
    • 13
  • Github auth provider in tauri app
    f

    floyare

    03/12/2023, 4:55 PM
    I have a problem with my tauri app. I want to create account system in my app but while registering OAuth app in github I need to specify app Homepage URL. With what I must fill this field up to have it working on my tauri app?
    s
    • 2
    • 3
  • Local Login with Provider Testing
    j

    jdgamble555

    03/12/2023, 7:31 PM
    I have 3 logins (none use a password) - Login with Google - Login with Apple - Login with Magic Link I need to test my local database queries, which I need to be logged in todo that. How can I tests these logins programmatically (with Vitest / Playwright) so that I can ultimately test my application queries? I don't need to test the login process, just test the queries for a logged-in user. I don't believe in passwords, so not sure how to do this? J
    g
    • 2
    • 8
  • Query entries by an array of uuids
    d

    davidf

    03/12/2023, 7:33 PM
    Hi there, I'm trying to filter down the results by a given list of ids. My posts look like this:
    Copy code
    [
      {
        id: 'uuid',
        authorid: '1', // as uuid
      },
      {
        id: 'uuid',
        authorid: '2', // as uuid
      }
    ]
    And I'm trying to filter down by a given list of users:
    Copy code
    const userIds = [uuid, uuid, uuid] // etc
    This is how I've tried filtering (following the docs):
    Copy code
    query.filter("authorid", "cs", `{${mappedIds.join(",")}}`);
    I also tried:
    Copy code
    query.containedBy("authorid", mappedIds.join(","));
    But I'm getting the following error:
    Copy code
    {
      "code": "42883",
      "details": null,
      "hint": "No operator matches the given name and argument types. You might need to add explicit type casts.",
      "message": "operator does not exist: text @> unknown"
    }
    I'm not sure how I'd typecast this? 🤔 anyone got a clue?
    g
    • 2
    • 2
  • Have to double submit signIn before navigating to (NUXT)
    c

    christer

    03/12/2023, 8:38 PM
    I have an odd issue where I have to submit the sign in form two times before it redirects to the next page. I have console logged the data from the
    client.auth.signInWithPassword
    function, and it gets a session on the first submission, but it does not redirect using the
    navigateTo
    built in Nuxt function. I've tried the following: 1. Using the router instead of
    navigateTo
    2. Tried creating another function with the actual supabase function inside it, calling it with
    await
    within the
    signIn
    function. This seems to fix the submit on pressing enter issue, but not when clicking the button. 3. Setting a timeout of 2 seconds before doing the
    navigateTo
    part 4. Creating a `if(data.xx)`before the
    navigateTo
    , to ensure we have the session before. None of the above solves the issue. SignIn form:
    Copy code
    <form @submit.prevent="signIn">
      <label for='email'> E-mail</label>
      <input
        type="email"
        placeholder="Email"
        v-model="email"
        id='email'
      />
      <div class="element input password">
        <label class="atom" for='password'> Password </label>
        <input class="atom" 
          type="password"
          placeholder="Password"
          v-model="password"
          id='password'
        />
      </div>
      <button @click="signIn()">
        sign in
      </button>
    </form>
    SignIn function:
    Copy code
    const signIn = async () => {
        const {data, error} = await client.auth.signInWithPassword({
          email: email.value,
          password: password.value,
        })
        return navigateTo('/portfolio')
      }
    s
    • 2
    • 10
  • Should supabase.auth.signUp('email') send an email via InBucket when running locally?
    g

    gilroy

    03/12/2023, 8:51 PM
    As far as I can tell, I'm receiving all email types (password reset/magic links etc...) in InBucket except for "Confirm Your Email" signUp emails. The users are always automatically confirmed... Am I missing something?
    g
    s
    • 3
    • 6
  • How does Postgres roles & privileges translate into Supabase?
    c

    callumboase

    03/12/2023, 9:44 PM
    I'm learning Postgres and SQL, to help me better understand and use Supabase, however I'm confused by the different methods of authorization available in Postgres and how that translates into Supabase. Supabase clearly has Row-level-security, and I see how that matches up with Postgres clearly. However, a fair bit of authorization in Postgres seems to revolve are Roles, privileges and grants, and I'm not sure how this applies to Supabase. Here's an example of roles, privileges and grants and how some people talk about using them to control access to the database in Postgres. Lets say I have a database with 1 table: students. Within that table is 3 columns: name, school and date_of_birth. I want students to only be able only READ the name and school of all students, but teachers to be able to create, read, update and delete all data. First, I might create some roles (groups) like this: CREATE ROLE student; CREATE ROLE teacher; Then I would grant some privileges to these roles: GRANT SELECT (name, school) ON students to student; GRANT SELECT, INSERT, UPDATE, DELETE ON students to teacher; Then I could create some login roles (users): CREATE ROLE "teacher1" LOGIN; GRANT teacher TO "teacher1"; CREATE ROLE "student1" LOGIN; GRANT student TO "student1"; CREATE ROLE "student2" LOGIN; GRANT student TO "student2"; Now, if I'm logged into Postgres as student1 or student2 I can read-only the columns "name" and "school" from the students table. But if I'm logged into Postgres as teacher1, I can create, read, update and delete all columns in the students table. From what I can tell, all access control rules in Supabase are controlled via row-level-security? So I wouldn't create new database roles, privileges etc if I wanted to create those same permissions in Supabase? So how would I go about creating the same permissions in Supabase?
    g
    n
    • 3
    • 10
  • Using a different Postgres client implementation?
    i

    imagio

    03/12/2023, 10:12 PM
    I'm writing some code that accesses the database that could be shared between clients and edge functions. It seems like the Supabase-js client isn't the recommended way to connect to postgres from edge functions, the example uses the
    postgres
    module. I found
    postgres.js
    (https://github.com/porsager/postgres) which seems like a really nice API and I'm considering using it in code that might run both on the client and on edge functions. I don't see any reason not to use
    postgres-js
    instead of
    postgrest
    but I want to ask those with more experience if I'm missing some important functionality that only
    postgrest
    offers. Is anybody using an alternative postgres client such as postgres.js rather than the default postgrest-js client that is part of supabase-js? If so, are there any particular pitfalls that might result from doing so?
    s
    • 2
    • 3
  • How to use `order` with select and inner
    e

    Eryou Hao

    03/13/2023, 1:33 AM
    My code like this, but I can't use order, I want to use order by
    note_site_ref
    table's
    publishAt
    column.
    Copy code
    javascript
    const result = await supabaseClient
      .from('note')
      .select(`
        *,
        site!inner (
          id
        ),
        extra:note_site_ref!inner (
          publishAt
        )
      `, { count: 'exact' })
      .match({ 'site.id': siteId })
      .order('note_site_ref(publishAt)', { ascending: false })
      .range(from, to)
    but get the error:
    Copy code
    javascript
    {
      error: {
        code: 'PGRST100',
        details: `unexpected '(' expecting letter, digit, "-", "->>", "->", delimiter (.), "," or end of input`,
        hint: null,
        message: '"failed to parse order (note_site_ref(publishAt).desc)" (line 1, column 14)'
      },
      data: null,
      count: null,
      status: 400,
      statusText: 'Bad Request'
    }
    • 1
    • 1
  • Supabase auth + refreshing 3rd party auth token
    m

    meow

    03/13/2023, 3:24 AM
    How do I refresh a 3rd party auth token, such as from Google, and store the information in the user's session provider?
  • failed to link project in supabase CLI
    e

    EK

    03/13/2023, 3:34 AM
    dial error (dial tcp 54xxxx2:6543: connectex: No connection could be made because the target machine actively refused it.) I kept getting this message.I could deploy edge fn to it but could not link to set sercret. I could connect to the same DB via sql admin tool. I could link a different project. What can I do in this situation? Or is there any way to update secret without supabase CLI. thx
    s
    • 2
    • 18
  • Accessing supabase buckets with python client
    j

    jarvis

    03/13/2023, 3:42 AM
    Hi all, I am fairly new to supabase and I am trying to create a supabase storage bucket the python client but throws the error storage3.utils.StorageException: {'statusCode': 400, 'error': 'Invalid JWT', 'message': 'new row violates row-level security policy for table "buckets"'} I then tried javascript but a similar error is thrown. I then went in and added this policy to storage.buckets which i thought would by pass row-levle security CREATE POLICY "allow all" ON "storage"."buckets" AS PERMISSIVE FOR ALL TO anon, authenticated, pgsodium_keyholder, pgsodium_keyiduser, pgsodium_keymaker, service_role but to no avail, i am fairly confused and any help with creating a new bucket with python or javascript would be appreciated thanks!
    r
    • 2
    • 4
  • How to do a fuzzy full text search
    p

    Peanut

    03/13/2023, 3:48 AM
    I've googled and googled and found articles explaining how to do a fuzzy search and a full text search in Postgres. But I want to know is there a definitive guide (preferably from the Supabase devs) for how to implement the "best" search for Postgres on Supabase - an intuitive, useful search (so fuzzy to help the user find what they want). I've read this article: https://supabase.com/docs/guides/database/full-text-search and found it lacking (I've implemented FTS and it works 70% of the time but isnt fuzzy) I've read this one too: https://supabase.com/blog/postgres-full-text-search-vs-the-rest All it does is compare "basic" search with other tools. Doesn't explain how to implement a "good" (useful) search My alternative is using a 3rd party search tool like Elasticsearch/Algolia or something but I'd prefer to keep it inside the Supabase ecosystem.
    s
    t
    • 3
    • 5
1...164165166...230Latest