https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • realtime views
    j

    jt

    10/13/2022, 12:49 AM
    is it possible to create realtime views? do all tables joined in the view need to be realtime?
    g
    • 2
    • 17
  • Next.js getServerSideProps broken after supabase.js 2.0 and auth helpers update
    u

    매튜

    10/13/2022, 3:44 AM
    Copy code
    export const getServerSideProps = withPageAuth({
      redirectTo: '/',
      async getServerSideProps(ctx, supabaseServerClient) {
        const { data } = await supabaseServerClient(ctx)
          .from('users_vocabulary')
          .select('*', { count: 'exact' });
        return { props: { data } };
      }
    });
    Followed the updated guide on https://github.com/supabase/auth-helpers/blob/main/packages/nextjs/README.md, supabase logs shows 200 query but then nothing shows up in chrome network monitor. Any ideas?
    n
    • 2
    • 3
  • DB Function to Insert New Users
    f

    fettuccine

    10/13/2022, 5:13 AM
    Hello, I would like my DB Function to make a new record in public.userProfiles when a user is added to auth.users Here is my function and the trigger that calls it. What am I doing wrong? I've never used Postgres or SQL
    Copy code
    create or replace function public.handle_new_user() 
    returns trigger as $$
    begin
      insert into public.profiles (id, email)
      values (new.id->>id, new.email->>'email');
      return new;
    end;
    $$ language plpgsql security definer;
    and the trigger:
    Copy code
    create trigger on_auth_user_created
      after insert on auth.users
      for each row execute procedure public.handle_new_user();
    I'm using this so that my security rules have a record to check UID against
    g
    • 2
    • 6
  • help with AWS SES on deno. xmlhttprequest error
    r

    rbkayz

    10/13/2022, 5:25 AM
    hello community, i'm trying to write an edge function in deno that calls the sendEmail API using the AWS SDK (using esm.sh to fetch the package). However, running into an error "NetworkingError: xmlhttprequest is not defined". Been racking my brain over it. Tried a polyfill import - import "https://deno.land/x/xhr@0.1.0/mod.ts"; But when i add this line, supabase does not let me deploy the function to deno. Throws an error. Any suggestions or help will be incredible. Ty ty
  • v2.00 release breaks production authentication if documentation followed
    w

    whiskeywizard

    10/13/2022, 5:57 AM
    Hi, The documentation suggests loading Supabase JS via CDN:
    <script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js">
    With the release of v2, the above will fetch the breaking changes and completely brick all production applications using the CDN method due to the change of supabase.auth.signIn. The documentation should be updated to include a specific version in the CDN URL, at the very least.
    s
    • 2
    • 5
  • Auth v2 not working with jsdelivr or unpkg
    s

    Shecky

    10/13/2022, 6:36 AM
    Since yesterday i switched all Stuff to v2 because i had massive errors on my page. But for some reason the auth is not v2 in the unpkg package. I also checked jadelivr and latest version of supabase-js is 1.7.9. on unpkg it says it is 2.0.0 but simple aut.getUser throws an error: function is not defined I checked what the supabase const of my connection gives me back and there it says under the point url: https://name.supabase.co/auth/v1 instead of v2 Has annyone a fix for this? Having massive problems
    w
    g
    s
    • 4
    • 14
  • RPC function to get sum of specific columns does not work in the SQL Editor
    a

    Azura

    10/13/2022, 7:09 AM
    I'm currently implementing a rpc function as follow, however, it is not working.
    t
    g
    • 3
    • 8
  • Free tier requests
    t

    TomCarnay

    10/13/2022, 7:45 AM
    Apologies if this is a basic question - the free tier allows up to 50,000 monthly active use. How does this translate to number of API requests? Just in development working in my own I can hit several thousand API requests in one day. Is there a limit on number of API requests per user?
    s
    g
    • 3
    • 2
  • Two phase sign in
    c

    cats

    10/13/2022, 8:57 AM
    Hello, I have build authentication for user using email/password credentials. Yesterday I have connected Twilio account and can pass with no problem OTP auth. I'd like to connect these two auth systems to one, like firstly user send email/password and then OTP. Is it possible? Somewhere I just read that email/password/phone can't be in the same request. There is any way to work around this? Maybe: sign in (email/password) -> get phone number from auth.user -> sign out -> sign in (phone). ^^^It looks bad and feels nad about it....
    g
    • 2
    • 3
  • Broken link report
    r

    rick4shar

    10/13/2022, 10:08 AM
    Not sure the best place to report this: https://supabase.com/docs/guides/auth/auth-helpers/nextjs has a broken link to https://supabase.com/docs/reference/javascript/next/typescript-support#generating-types
    g
    • 2
    • 1
  • Using service key with nextjs
    p

    pvtctrlalt

    10/13/2022, 11:30 AM
    Hey am i being silly with this setup, trying to make an admin panel and using the service level key, although the website is not accesable by normal people i still want to be as safe as possible. i am currently calling a PostData function to send data to the back end
    Copy code
    const onSubmit = handleSubmit(async () => {
        setLoading(true);
        const userDetails:UserDetails = getValues();
        const merged = {...customer, ...userDetails};
        const res = await postData({
          url: "/api/supa/updatecust",
          data: merged
        });
    Copy code
    export const postData = async ({
      url,
      data
    }: {
      url: string;
      data?: any;
    }) => {
    
      const res: Response = await fetch(url, {
        method: 'POST',
        headers: new Headers({ 'Content-Type': 'application/json' }),
        credentials: 'same-origin',
        body: JSON.stringify(data)
      });
      if (!res.ok) {
        console.log('Error in postData', { url, data, res });
    
        throw Error(res.statusText);
      }
      const fresponse:any  = await res.json();
      return await fresponse;
    };
    then from the api folder i call a function in my supabase-admin in utils and return the results, this feels janky and weird
    Copy code
    const  updatecust = async (
      req: NextApiRequest,
      res: NextApiResponse
    ) => {
      if (req.method === 'POST') {
        try {
            const test:UserDetails = req.body;
            const cust = await updateCust(test);
            res.status(200).json({ cust });
        } catch (err:any) {
          console.log(err);
          res
            .status(500)
            .json({ error: { statusCode: 500, message: err.message } });
        }
       
      } else {
        res.setHeader('Allow', 'POST');
        res.status(405).end('Method Not Allowed');
       }
    };
    is there a better way to do this? goal is to hide api key. but this feels weird 5 step proccess and janky
    a
    • 2
    • 7
  • Supabase is down?
    x

    xuan

    10/13/2022, 11:40 AM
    I tried to connect to the supabase app. But I can't. My application is also can not work
    c
    s
    • 3
    • 7
  • Google auth not working
    v

    ven

    10/13/2022, 12:04 PM
    getting the following error
    t
    b
    • 3
    • 23
  • Auth-helpers-sveltekit v2 -- supabaseServerClient?
    b

    babeard

    10/13/2022, 12:28 PM
    While trying to upgrade I noticed that
    supabaseServerClient
    was no longer available. Suppose I wanted to createUser on the server side, is the recommended way going forward to use createClient with the service role key?
    d
    j
    • 3
    • 5
  • Checking if a row with the same element already exists
    s

    Silver.

    10/13/2022, 1:56 PM
    Hello, I am new to supabase and I struggle with update and insert(in a database). I need to be able to update a row if the row already exist and insert it if it doesn't exists. I tried using the command upsert but it didn't work. (I might have used it wrong but i couldn't find an exemple of it with 2 different confilcts) . So I using delete and insert but it didn't work either. Does anyone knows how I can make some kind of if to check if a row with the same 'user' and 'letter' has been already inserted into the database ? Here's a screenshot of my database and code to make it a little bit more understandable : (Sorry if my question is not well written I am not a native speaker.)
    g
    • 2
    • 11
  • Have few issues with linkedin signIn
    t

    tyakymiuk

    10/13/2022, 2:21 PM
    My app requires a login using linkedin but when using Supabase solution as per doc i have 2 following issues 1) If i'm trying to login (even from a new device, or second time from the same browser where I was logged in previously) I'm being redirected to "Welcome back page" instead of a screen with my company's logo (and permission request). See screenshot 1, screenshot 2 is from another app that shows what I want to have. 2) On other apps when I'm trying to relogin after signout it does not force me to submit anything (email and password in login redirect), looks like it's 'remembering' that I granted everything but in my current app every time I click 'login with linkedin' button I see 'Welcome back' screen. Is it possible to do it as described in the beginning of the second question? 3) login does not work in case I'm trying to login with a profile that does not have profile IMG (after redirect I have this issue in the url: ?error=server_error&error_description=Unable+to+exchange+external+code%3A+AQQcwhaK4Q2zwl5p_uevx88g_DuM_u8cFyR4-Vw35iWSeKdRxewaPkC6y8CM-v8AFXJcGAniR_4wUVaTlRhmB1o0GS92xTS_0rnUTn_ZqiyTKefztCKYlwNcUtabRRIVV2xY9bPjsuzFyyonzMi9szpFJaMPDoOVSGGXzpj8yMUywAhxY0rQHRfmKzL6S0wPpGBAT0GY0FEHIRVwBTI) thanks for any help!
  • React Realtime subscription not working
    j

    Jeremy Deceuster

    10/13/2022, 2:43 PM
    I'm trying to listen to inserts on my "messages" table in a React Project, but when I add a message to the table, the console log is not printed. Here's the code:
    Copy code
    useEffect(() => {
        console.log("listening");
        supabase
          .channel("public:messages")
          .on(
            "postgres_changes",
            { event: "INSERT", schema: "public", table: "messages" },
            (payload) => {
              console.log("Change received!", payload);
            }
          )
          .subscribe((status) => console.log(status));
      }, []);
    What I see in the console: "listening" "SUBSCRIBED" Realtime is enabled, I removed StrictMode, tried older and version 2.0.0 of supabase/supabase-js. Anyone can help me with this?
    g
    m
    • 3
    • 7
  • Detect disconnection of realtime channel
    e

    enyo

    10/13/2022, 2:47 PM
    How can I detect if there is an issue with my realtime connection? Will the callback function provided to
    .subscribe()
    be invoked again with another status? Does supabase realtime have auto-reconnect capabilities or is this up to me to implement?
    g
    • 2
    • 2
  • Cookies not deleting after signout
    p

    peanuts

    10/13/2022, 3:27 PM
    am experiencing a bug with supabase server side authentication, i followed this (https://blog.bitsrc.io/setting-up-server-side-auth-with-supabase-and-nextjs-15cbe98956a9) tutorial on how to set cookies after user logins in using setAuthCookie(req, res), but when the user signs out the cookie dosent get deleted like supabase auth token in localstorage, is there anything am missing ?
    j
    • 2
    • 1
  • Need help adding user.id to array column
    k

    kvnfo

    10/13/2022, 3:55 PM
    I have a column in the table called "interested" I am trying to attach ther user.id to this table. I have the column as text and as an array. I've tried several different methods and cannot get it working. is .update the right way? Currently it just overwrites whatever is in the column.
    g
    • 2
    • 3
  • get user function supabase.auth.user()
    k

    khairulhaaziq

    10/13/2022, 3:59 PM
    Hi I am trying to follow Jon Meyer's tutorial of Supabase + NextJS. However I think some of the functions are deprecated, as the photo attached. What is the newest function for getting user?
    g
    • 2
    • 2
  • Google Auth Enabled, but getting 'provider is not enabled' 400 Error
    n

    NicoNico

    10/13/2022, 5:25 PM
    * Google is enabled with my oAuth credentials from the Google Auth console as listed in the guide. * Auth redirect callback in Google Cloud platform looks ok * Google app is set to External, and is still in "Testing", but I could publish it if that helps. I also tried deploying the app to Vercel to see if it was a localhost issue specifically but the deployed version also didn't help.
    • 1
    • 1
  • How frequent should I pull something from a DB?
    l

    lifelesspizza

    10/13/2022, 5:31 PM
    Hello! So lets say our website has virtual coins that I want to show when user signs in. How frequent should I pull that from a DB? Should I pull it and show it everytime he refreshes a page or should it be somehow cached and pulled only when the change occures? What is the best way/practice for this? Thanks,
    g
    • 2
    • 1
  • FATAL entries in Log Explorer
    t

    thestepafter

    10/13/2022, 6:37 PM
    I'm seeing FATAL entries in the log explorer this morning. Is anyone else seeing this? Is it something I should be concerned about? I'm assuming it is just bots.
    g
    • 2
    • 2
  • Table join only returning 1 matching column instead of multiple
    e

    Ethanxyz

    10/13/2022, 9:06 PM
    Database Setup ------- Table
    tournaments
    - - id - title - matches ( FK
    id
    field in
    t_matches
    ) Table
    t_matches
    - id -created_at - t_id ( FK
    id
    field in
    tournaments
    ) - t_match ( FK
    id
    field in
    t_match
    ) -- Holds details about match Table
    t_match
    - id - title - state - participants ( FK
    id
    field of
    participants
    table ) Table
    t_match_participants
    - id - match_id ( FK
    id
    field of
    t_match
    - participant ( FK
    id
    for
    profiles
    table ) The issue I am having is using this query...
    Copy code
    js
    let { data, error, status } = await supabase
            .from("tournaments")
            .select('*, matches(*, t_match(*, participants(*)))')
            .eq("id", id).single();
    Using this query ^ I am expecting to retrieve... 1. Multiple
    matches
    , returning as an array since there are multiple matches in my database using the
    t_id
    of
    1
    2. Multiple
    participants
    , returning as an array since there are multiple participants for the given
    match_id
    But instead I am only getting.... 1. A single
    participant
    object 2. A single
    match
    object Below I will post some photos of the Tables + Data. I would appreciate some help here. Thank you. Image 1 -
    tournaments
    Image2 -
    t_matches
    Image3-
    t_match
    Image4 -
    t_match_participants
    Here is my current returned data...
    Copy code
    json
    {
       "id":1,
       "created_at":"...",
       "title":"Test Tournament",
       "min_participants":2,
       "max_participants":5,
       "start_time":null,
       "matches":{
          "id":1,
          "created_at":"...",
          "t_id":1,
          "t_match":{
             "id":1,
             "created_at":"...",
             "name":"Match Round 1",
             "state":"ongoing",
             "participants":{
                "id":1,
                "created_at":"...",
                "match_id":1,
                "participant":"48191...",
                "isWinner":null
             }
          }
       }
    }
    j
    g
    • 3
    • 6
  • LIKE - Not working on Foreign Table
    c

    cbunge3

    10/13/2022, 9:38 PM
    > is this possible to have a LIKE on a foreign tables field?
    g
    • 2
    • 3
  • querying supabase int field by passing a string
    c

    Cheqo

    10/13/2022, 9:54 PM
    Hello, I am using next js and I get the query string from my url, and I pass this string to query some data, but in postgres that field is a number, do I need to do any conversions?
    d
    • 2
    • 1
  • User Management Starter allows updating all avatars?
    d

    dwma

    10/13/2022, 11:52 PM
    The last two lines of the current User Management Starter:
    Copy code
    create policy "Anyone can update an avatar." on storage.objects
      for update with check (bucket_id = 'avatars');
    Would that not allow a malicious user to update someone else's avatar? Is the security through obscurity of the object location/url? Or am I just misunderstanding something? An update doesn't produce a new URL, right? It changes the object at the referenced path so that the referenced avatar_url wouldn't change but the image at the end of the url would?
    g
    • 2
    • 14
  • Upsert all keys must match
    t

    Tony_n

    10/14/2022, 12:21 AM
    I know the problem is this open issue https://github.com/supabase/postgrest-js/issues/173 But I am not sure how to edit the trigger. I thought I understood but the upsert still fails so I am assuming I did something wrong. My table name is host_activities and my column is id Below is my trigger sql code which I got from that issue
    Copy code
    -- Change host_activities and its sequence according to your table
    CREATE OR REPLACE FUNCTION host_activities_null_id_is_default() RETURNS TRIGGER AS $$
    BEGIN
      NEW.id = coalesce(NEW.id, nextval('host_activities_id_seq'));
      RETURN NEW;
    END;
    $$ LANGUAGE plpgsql;
    CREATE TRIGGER host_activities_null_id_is_default 
    BEFORE INSERT ON host_activities FOR EACH ROW EXECUTE PROCEDURE host_activities_null_id_is_default();
    • 1
    • 1
  • Using external CDN (ex. Cloudfront) for Supabase
    c

    Chae

    10/14/2022, 1:18 AM
    Hi I have a issue with using CDN with Supabase. Is there a feature for external CDN cache (we are thinking cloudfront)? Loading(streaming) uploaded short videos are quite slow with supabase and cdn its working with.
    o
    z
    • 3
    • 6
1...444546...230Latest