https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Auth UI on Next.JS causing Runtime Error
    b

    bob_the_robot

    01/09/2023, 11:38 PM
    Hey folks! I followed the tutorial from https://supabase.com/docs/guides/getting-started/tutorials/with-nextjs#launch and when i run the
    npm run dev
    command I am greeted with this error Any idea what went wrong? Fresh install, only changes and updates are what is in that document.
    g
    a
    t
    • 4
    • 9
  • Using GET request to fetch record from Directus, Supabase to pass URL for image
    p

    pearcy

    01/10/2023, 1:35 AM
    Draftbit (front end React app) needs a URL passed through to show images. I can manually add a URL in Draftbit from Cloudflare and it works (shows image). However, I can not figure out how to pass through a URL from Directus/Supabase to do the same (as part of the database table). My stack: Draftbit (frontend) --> Supabase (Postgres) --> Directus ( API layer, local install) Happy to do this manually but ideally I would find a solution to do the following: -- tie the URL to my "article" database/table -- upload article info with image URL -- utilize a CDN for efficient image processing. There are a few posts/searches that talk about errors for getPublicUrl returns but I am looking for a simple, GUI/low code based way to tie my image URL (fromCloudflare or Supabase object storage) and tie it to my Supabase "article" table. Any suggestions would be greatly appreciated. I have found very good, detailed solutions for solving this programmatically but nothing in a low code fashion. For reference, here are what seem to be very good solutions that are more involved. Supabase using their cloud storage (https://github.com/supabase/supabase/discussions/5196) How to manage your content with Directus and Cloudinary -- code included for building a Vue front end for Directus that points to Cloudinary (https://medium.com/birdie-ai/how-to-manage-your-content-with-directus-and-cloudinary-ded6ddd9a4b1)
    g
    • 2
    • 1
  • About types and querying foreign keys
    p

    pepegc

    01/10/2023, 1:57 AM
    I have a table
    asset
    with a foreign key (
    asset_type_id
    ) that links it to table
    asset_type
    .
    g
    • 2
    • 8
  • State Management w Queries
    u

    𝖘𝖚𝖗𝖌𝖎𝖊𝖇𝖔𝖎 | Drooler

    01/10/2023, 4:06 AM
    I've been experiencing state management issues when saving Queries for the past week. Using a single browser tab, saved Queries are randomly overridden. This is an issue because we're using Queries for scheduling cron jobs that our app's dependent on; however, if a cron job is erased or updated without our team explicitly doing it, it creates issues.
    g
    • 2
    • 4
  • Cannot destructure property 'supabaseUrl' of 'getConfig(...)' as it is undefined.
    n

    NADEE_MJ

    01/10/2023, 4:07 AM
    Hi, I am trying to setup a project using the supabase auth-helpers-sveltekit package and keep getting this error. Found this (https://giterhub.com/repository/activity/supabase-community/supabase-auth-helpers) online and I have a hooks.client.ts and hooks.server.ts file setup with $lib/supabase imported in both but it still just gives me this error. Anyone know what the problem might be?
    • 1
    • 1
  • Storage API Help
    i

    itzomen

    01/10/2023, 4:23 AM
    Hey guys, I'm getting started with Superbase and was wondering if there's a way to protect stored files i.e render the files ( image or video ) on the client-side but prevent any download of that file. I see it's possible to protect the file with the permission/auth system of Superbase but after giving access to the user, is there a way to prevent any download. I'm currently thinking about setting up a proxy for the backend but was wondering if there's a better way
    o
    • 2
    • 2
  • Help translating query with join table
    h

    honkstyle

    01/10/2023, 6:49 AM
    Hey guys, given the following two tables
    Copy code
    CREATE TABLE IF NOT EXISTS problems
    (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        statement text not null,
        placeholder text not null,
        tests text not null,
        created_at timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
        updated_at timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
        deleted_at timestamptz
    );
    
    ALTER TABLE problems enable row level security;
    
    CREATE TABLE IF NOT EXISTS problems_mapping
    (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        problem_id bigint not null,
        course_id bigint not null,
        section_id bigint,
        created_at timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
        updated_at timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
        deleted_at timestamptz,
        unique(problem_id, course_id, section_id),
        FOREIGN KEY(course_id) REFERENCES courses(id) ON DELETE CASCADE,
        FOREIGN KEY(section_id) REFERENCES sections(id) ON DELETE CASCADE,
        FOREIGN KEY(problem_id) REFERENCES problems(id) ON DELETE CASCADE
    );
    How do I translate the following query
    Copy code
    select p.* from problems as p inner join problems_mapping as pm on p.id = pm.problem_id and pm.course_id = 1;
    With the javascript library?
    • 1
    • 1
  • how to monitor supabase edge functions for errors?
    i

    iamallin

    01/10/2023, 9:04 AM
    Hi, couldn't find any info about this. New to deno as well. My worry is my edge functions are failing and I never find out about it. Typically, you wold use a monitoring solution for this. Doesn't look like supabase has it yet. So what are folks using to monitor their edge functions? Thanks!
    j
    m
    • 3
    • 3
  • Can't update a table row from the dashboard if table has trigger on updated_at column
    i

    iamallin

    01/10/2023, 9:09 AM
    Hi, I have a table with a trigger to update updated_at column before every update. I am trying to change a column value for a specific row in this table from the dashboard. I get this error. Failed to run SQ query. moddatetime must be fired for row. So it looks like the trigger is preventing me from update a column. If I disable it, I am able to update column. Is there a way around this? I would like to be able to update a column without constantly disabling and enabling the trigger. Thank you!
    s
    • 2
    • 4
  • [SOLVED] Cannot import Stripe on Supabase Edge function
    l

    lake_mattiato

    01/10/2023, 9:18 AM
    using the following import from the dijonmusters/happy-days github repository:
    Copy code
    import Stripe from "https://esm.sh/stripe?target=deno";
    But getting the following error message when deploying
    Copy code
    Bundling create-stripe-customer
    Error: Error bundling function: exit status 1
    file:///src/index.ts
    error: Uncaught (in promise) Error: Relative import path "http" not prefixed with / or ./ or ../
          const ret = new Error(getStringFromWasm0(arg0, arg1));
                      ^
        at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:312:19)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:79439)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1388039)
        at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1862894)
        at __wbg_adapter_18 (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:146:6)
        at real (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:130:14)
    j
    • 2
    • 2
  • so i want to create a confirmation email with tailwind but can't include the cdn in the template.
    g

    Gitanes

    01/10/2023, 10:36 AM
    i'm using auth supabase and want to send nice looking emails to users. i found tailwind email templates but to display properly i have to include the tailwind cdn in the message. supabase removes the header from the template and only keeps the body. how can i fix this?
    h
    • 2
    • 1
  • DB migration error when signing in with OTP
    h

    hefler

    01/10/2023, 11:29 AM
    I've been trying to use
    signInWithOtp
    (on NodeJS) and it returns
    AuthRetryableFetchError: {}
    . Looking into the auth logs I see the following error:
    Copy code
    `
    Event Message
    running db migrations: error executing migrations/[REDACTED]_modify_users_email_unique_index.up.sql, sql: -- this change is relatively temporary
    -- it is meant to keep database consistency guarantees until there is proper
    -- introduction of account linking / merging / delinking APIs, at which point
    -- rows in the users table will allow duplicates but with programmatic control
    
    alter table only auth.users
      add column if not exists is_sso_user boolean not null default false;
    
    comment on column auth.users.is_sso_user is 'Auth: Set this column to true when the account comes from SSO. These accounts can have duplicate emails.';
    
    create unique index if not exists users_email_partial_key on auth.users (email) where (is_sso_user = false);
    
    comment on index auth.users_email_partial_key is 'Auth: A partial unique index that applies only when is_sso_user is false';
    
    alter table only auth.users
      drop constraint if exists users_email_key;
    : ERROR: cannot drop constraint users_email_key on table users because other objects depend on it (SQLSTATE 2BP01)
    I have little understanding of SQL so some help of what's going on and what to do would be much appreciated.
    g
    • 2
    • 5
  • How do I access the supabase auth session in react once a user has logged in?
    a

    anewcar

    01/10/2023, 12:16 PM
    Hi, At the moment I can log in and get the user user but as soon as I refresh the page or close the app and reopen these details are gone. But I can see the session in the localstorage in web developer. Thank you!
    b
    • 2
    • 1
  • PostgrestBuilder._parseResponse exception
    g

    goldyman

    01/10/2023, 12:43 PM
    I have an issue that i cannot resolve. I keep getting an exception for a simple select to my table, which has policy for SELECT to Enable read access for all users. This is my query
    Copy code
    dart
    supabaseClient
              .from('users')
              .select<PostgrestListResponse>('id')
              .eq('username', userName)
              .limit(1)
              .single();
    and the stacktrace
    Copy code
    #0      PostgrestBuilder._parseResponse
    package:postgrest/src/postgrest_builder.dart:323
    #1      PostgrestBuilder._execute
    package:postgrest/src/postgrest_builder.dart:198
            <asynchronous suspension>
    #2      PostgrestBuilder.then
    package:postgrest/src/postgrest_builder.dart:400
            <asynchronous suspension>
    Copy code
    {
      "headers": [
        {
          "cf_cache_status": "DYNAMIC",
          "cf_ray": "78756a92c6578ee0-SOF",
          "content_length": null,
          "content_location": null,
          "content_range": null,
          "content_type": "application/vnd.pgrst.object+json; charset=utf-8",
          "date": "Tue, 10 Jan 2023 12:29:06 GMT",
          "sb_gateway_mode": null,
          "sb_gateway_version": "1",
          "transfer_encoding": "chunked",
          "x_kong_proxy_latency": "0",
          "x_kong_upstream_latency": "3"
        }
      ],
      "origin_time": 88,
      "status_code": 406
    }
    g
    • 2
    • 14
  • Could not find a relationship between 'record' and 'user_id' in the schema cache
    k

    kresimirgalic

    01/10/2023, 2:14 PM
    What i am trying to achieve is to get an unread count in threads table and return threads columns which i am getting, the problem i am facing right now is that i cant populate user_id which is a relation to profiles table so i am getting this error. This is the sql function:
    Copy code
    CREATE OR REPLACE FUNCTION get_threads_by_user_id(userId uuid)
    returns table(id uuid, whom uuid, subject text, user_id uuid, unread_count bigint) AS $$
    BEGIN
        RETURN QUERY 
        SELECT threads.id,threads.whom,threads.subject, threads.user_id, COUNT(CASE WHEN threads_message.is_read = false THEN 1 ELSE NULL END) AS unread_count
        FROM threads
        JOIN threads_message ON threads.id = threads_message.thread_id
        WHERE threads.user_id = userId
        GROUP BY threads.id;
    END;
    $$ LANGUAGE plpgsql;
    and this is the supabase call with rpc:
    Copy code
    const { data, error } = await supabase
          .rpc('get_threads_by_user_id', {
            userid: userId,
          })
          .select('*, user_id(*)');
  • Download Edge Function source code?
    d

    drgonxoo

    01/10/2023, 2:14 PM
    Is it possible to download the souce of a function I have already deployed? I stupidly deleted it from my local disk before i pushed it to git 😦
    g
    b
    g
    • 4
    • 6
  • inviteUserByEmail doesn't exist supabase-js@2
    m

    mcdaded

    01/10/2023, 2:33 PM
    I was setting up an edge function to allow users to invite others via email but hit an error that supabase.auth.api.inviteUserByEmail doesn't exist. I downgraded createClient from https://esm.sh/@supabase/supabase-js@2 to https://esm.sh/@supabase/supabase-js@1.33.1 and it works as expected in the documentation https://supabase.com/docs/reference/javascript/auth-admin-inviteuserbyemail I am using the SERVICE_ROLE_KEY not the ANON_KEY to create the client. Was there some refactoring in the latest release that hasnt been updated in the documentation yet?
    g
    • 2
    • 2
  • Looking for storage documentation examples?
    s

    salzar

    01/10/2023, 3:28 PM
    Hi, I’m trying to look for a more in depth documentation on storage with examples. Is this the only resource there is? https://supabase.com/docs/guides/storage
    g
    • 2
    • 4
  • Realtime, sending a broadcast triggers presenceState sync event
    i

    imzino

    01/10/2023, 3:48 PM
    is this expected behaviour ??
    h
    • 2
    • 4
  • Retrieve Function Caller Auth Info while using Service Role Key
    a

    anggoran

    01/10/2023, 4:11 PM
    I'm not sure if function with service role key okay to be called in client side (Flutter) or not, but here is my code (for Deno):
    Copy code
    javascript
    const supabase = createClient(supabaseURL!, supabaseServiceRole!, {
          auth: {
            autoRefreshToken: false,
            persistSession: false,
          },
          global: { headers: { Authorization: req.headers.get("Authorization")! } },
        });
    
        const { data: isAdmin }: { data: boolean | null } = await supabase
          .rpc("is_admin")
          .single();
    
        if (!isAdmin) {
          return new Response(
            JSON.stringify({ message: "User is not Super Admin." }),
            {
              headers: { "Content-Type": "application/json" },
              status: 403,
            }
          );
        }
    
        const adminAuth = supabase.auth.admin;
    
        const { data: user } = await adminAuth.inviteUserByEmail(email, {
          data: {
            name: name,
            role: role,
            super_admin: super_admin,
            supporter_id: supporter_id,
          },
        });
    j
    g
    • 3
    • 10
  • We're getting spammed from a Cloudflare ip
    r

    Reuben

    01/10/2023, 4:15 PM
    Heya, we're getting serious traffic from a specific IP toward the Auth endpoint. Looks like it's from a cloudflare assigned IP. Is this something that should be blocked from Supabase side, or should this be done from us. (I've confiscated the full IP)
    "remote_addr":"2a06:************"
    g
    • 2
    • 13
  • How to get Postgres logs (docker)?
    j

    josephbuchma

    01/10/2023, 4:20 PM
    I'd like to observe postgres log in real-time by running
    Copy code
    docker logs supabase_db_myproject -f
    Instead, I see following entries in Postgres container logs :
    Copy code
    2023-01-10 10:52:42.450 UTC [47] LOG:  redirecting log output to logging collector process
    2023-01-10 10:52:42.450 UTC [47] HINT:  Future log output will appear in directory "/var/log/postgresql".
    Executing
    SHOW logging_collector
    indeed returns "on". So I decided to disable it in the
    postgresql.conf
    , and to my surprise, found out that logging collector is not actually enabled there (
    logging_collector = off
    in
    /etc/postgres/logging.conf
    file). I'm confused. Any help is very much appreciated!
  • How can I select only confirmed users?
    j

    javierguzman

    01/10/2023, 4:56 PM
    Hello all, I want to select people/profiles around certain location, however, I just want to show people who has verified their email, how can I achieve that? So far I have this:
    Copy code
    create or replace function get_people(radius int, point text, get_all_people boolean)
    returns setof profile
    language plpgsql
    as $$
    begin
      if get_all_people then
        return query select * from profile where id != auth.uid();
      else
        return query select * from profile where id != auth.uid() and ST_DWithin(location, point::geometry, radius);
      end if;
    end;
    $$;
    I have tried to access auth.confirmation_token and stuff like that but it seems that only auth.uid() is available. Thank you in advance and regards
    • 1
    • 1
  • function don't exist
    g

    goldyman

    01/10/2023, 5:00 PM
    I had created several function running on user creation thus on auth.users. All the functions were in public schema. I moved couple of functions in auth schema and the error disappeared. But I can't the see those function anymore. How can I see them and or delete them.
    g
    • 2
    • 8
  • For the auth email templates, is TokenHash derived from Token?
    p

    Ponku

    01/10/2023, 5:32 PM
    Based on some very annoying requirements, I have to do some mildy janky stuff with the auth emails. The answer to this question will greatly affect how my implementation goes.
    g
    • 2
    • 3
  • Storage Schema Functions
    j

    jh

    01/10/2023, 5:46 PM
    Hi, I was able to create a function under the storage schema. However I can no longer view or edit it because we don't have the option to change schema in the view page, nor is it listed anywhere other than when you try to assign it to a trigger? Is this intentional? It appears to be a bug.
    g
    • 2
    • 10
  • text or varchar?
    j

    jinsley8

    01/10/2023, 5:51 PM
    I see in many tutorials on Supabaase and other websites of people using the
    text
    datatype in their Supabase tables but I thought only the
    varchar
    datatype can be indexed and is much faster? Any insight on this?
    g
    u
    • 3
    • 5
  • Virtual column for tree like structure
    ł

    ŁukaszW.

    01/10/2023, 5:52 PM
    I have a structured users in the DB , wish to just get first level set of users restricted by RLS, and then using virtual column by postgres function get the further structure In profiles table I have user_id and parent_id for each row. in js client :
    Copy code
    .select("name, surname, children, code, id:user_id ")
          .eq("parent", ctx.user.id);
    in the db :
    Copy code
    create function children(profiles)
      returns jsonb
      language plpgsql
      security definer
      as
      $$
        begin
        return (select array_to_json(array_agg(profile)) from (
          select user_id as id, name, surname, code, from profiles where parent = $1.user_id) profile);
        end;
      $$
    I wish just use the function recursively in sub-query but it doesn't work . Any ideas ?
  • one click deployment for digital ocean?
    s

    salzar

    01/10/2023, 6:50 PM
    I remember there used to be easy deployment for digital ocean, now I don’t see it anymore? Is there anything similar?
  • Property 'session' does not exist on type 'SupabaseAuthClient'.
    c

    Cheqo

    01/10/2023, 6:52 PM
    I am trying to use supabase with react native and I am following this tutorial - https://www.supabase.jp/docs/guides/with-expo Code provided in the tutorial doesn't work:
    Property 'session' does not exist on type 'SupabaseAuthClient'.
    Copy code
    export default function App() {
      const [session, setSession] = useState<Session | null>(null)
    
      useEffect(() => {
        setSession(supabase.auth.session())
    
        supabase.auth.onAuthStateChange((_event, session) => {
          setSession(session)
        })
      }, [])
    
      return (
        <View>
          {session && session.user ? <Account key={session.user.id} session={session} /> : <Auth />}
        </View>
      )
    }
    g
    g
    • 3
    • 3
1...939495...230Latest