https://supabase.com/ logo
Join Discord
Powered by
# help
  • r

    regex

    02/05/2022, 8:40 PM
    #843999948717555735 I have a problem with next.js/SSR and Supabase. I am following the next.js starter tutorial but I wanted to load the profile before the page render. To achieve that I moved the respective code under api/
    Copy code
    export default async function handler(
      req: NextApiRequest,
      res: NextApiResponse
    ) {
      const user = await supabase.auth.user();
      const { data, error, status } = await supabase
        .from("profiles")
        .select(`username, country, avatar_url`)
        .eq("id", user?.id)
        .single();
    
      if (error) return res.status(status).json({ error: error.message });
      return res.status(200).json({ user: data });
    }
    However, I am getting an error response
    Copy code
    error: "invalid input syntax for type uuid: \"undefined\""
    Can't I reach logged in user's id inside the API folder?
    g
    • 2
    • 6
  • g

    garyaustin

    02/05/2022, 9:12 PM
    SSR and user
  • e

    Eryou Hao

    02/06/2022, 8:12 AM
    Hi Supabase, I have a bug where if a field is of type text, when I want to change it to an array type, it doesn't work.
  • h

    hotbelgo

    02/06/2022, 10:26 AM
    Can anyone help with a signup flow and RLS. I have this code
    Copy code
    export async function signUp(credentials: Credentials, name: String): Promise<Player> {
        // Create the user
        let userRes = await supabase.auth.signUp(credentials);
        console.log("signUp", userRes)
    
        if (userRes.error) return Promise.reject(userRes.error);
    
        // Create and insert a Player
        const newPlayer = {
            user_id: userRes.user.id,
            name
        }
        // insert takes a list
        const { data, error } = await supabase.from(PLAYERS).insert([newPlayer])
        if (error) return Promise.reject(error)
        return data[0]
    }
    And setup Select and Insert RLS with
    (role() = 'authenticated'::text)
    But I get an RLS error about creating new player
  • a

    anggoran

    02/06/2022, 10:57 AM
    Hello, I am new to supabase. Today I use the table editor but I realized that the table is by default added to public schema. Can we create new schema or am I missing something?
  • j

    joshcowan25

    02/06/2022, 11:00 AM
    Try creating a new field with type text and Define as Array checked. I think you can't change this after creation of the field.
  • j

    joshcowan25

    02/06/2022, 11:03 AM
    Hi! I'm working on a project where I need to use variables to define my request and more precisely one where I could get data for foreign tables. My code is working, except for the part with Order and Range. The returned list contains my foreign tables, but it is not ordered and I think the count doesn't work.
    • 1
    • 2
  • a

    anggoran

    02/06/2022, 11:27 AM
    oops I found it by run sql script via sql editor hahaha
  • o

    osaxma

    02/06/2022, 12:14 PM
    it's most likely a PostgreSQL error that's not shown on the UI because
    text
    cannot be implicitly casted to
    text[]
    . If your table is empty and does not have data, just drop the column and add it again with the new type. Otherwise, if you need to cast existing data from
    text
    to
    text[]
    you can write a query that uses
    string_to_array(value_from_column, delimiter)
    ... see this answer for how it can be done using the SQL editor: https://stackoverflow.com/a/27195528/10976714
  • o

    osaxma

    02/06/2022, 2:09 PM
    You may need to specify the schema in the Policy — ie
    auth.role() = ….
  • h

    hotbelgo

    02/06/2022, 2:25 PM
    @User - this is what I have
  • s

    Sealion

    02/06/2022, 3:23 PM
    What is the different between Auth and Auth (Server only?) If I am using for example sveltekit and using endpoints (call supabase from server, not frontend) should I focus on the documentation about server then?
    s
    o
    • 3
    • 8
  • o

    osaxma

    02/06/2022, 5:38 PM
    honestly, I don't use the UI to create policies so I'm not very familiar with it.. it'd be helpful though if you share the error that you're receiving
  • h

    hotbelgo

    02/06/2022, 5:43 PM
    Here you see that the confirmation that the user was added to the users/auth table, and then the error that occurred trying to create the player @User
    o
    g
    • 3
    • 40
  • h

    hotbelgo

    02/06/2022, 5:55 PM
    hmm, same errorm, but perhaps this wll be an easier way to iterate
  • s

    Scott P

    02/06/2022, 7:42 PM
    Server only
  • s

    sockenguy

    02/06/2022, 9:00 PM
    hmm fuck I think I forgot my database password in supabase, any way to recover it? Or do I need to create a new database?
  • s

    sockenguy

    02/06/2022, 9:00 PM
    It is not the anon key right?
  • o

    osaxma

    02/06/2022, 9:05 PM
    try this in the SQL Editor and see if it works:
    Copy code
    sql
    alter user postgres with password 'new_password';
  • s

    sockenguy

    02/06/2022, 9:05 PM
    is the default user postgres?
    o
    • 2
    • 1
  • s

    sockenguy

    02/06/2022, 9:06 PM
    where can I run queries in the dashboard?
  • s

    sockenguy

    02/06/2022, 9:06 PM
    ok found the query ui
  • j

    joshcowan25

    02/07/2022, 1:29 AM
    Order
    • 1
    • 1
  • l

    lavenderlav

    02/07/2022, 3:25 AM
    Is it possible to change server regions? or is there anyway to migrate my current db to a new project located in a different region?
  • j

    jdgamble555

    02/07/2022, 3:35 AM
    How do I create a trigger to make sure
    created_at
    is not changed by the user? I'm thinking:
    Copy code
    typescript
    create trigger posts_created_at after update on posts
    OLD.created_at === NEW.created_at or undo transaction?
    I'm not sure how to confirm this...
    s
    • 2
    • 2
  • g

    garyaustin

    02/07/2022, 4:20 AM
    There may be some automated way to deal with that, but at a minimum if you have a trigger on update that does new.created_at = old.created_at the value the user provided would be ignored.
  • j

    jdgamble555

    02/07/2022, 4:21 AM
    right, but how? I would think this would be a standard security issue that someone has already solved, but I can't find anything
  • g

    garyaustin

    02/07/2022, 4:35 AM
    Well if no better way exists, or no one else responds with it, you just do an update trigger on your table and call a function that does new.created_at = old.created_at and returns new (which it has to do anyway).
  • j

    jdgamble555

    02/07/2022, 4:45 AM
    I don't think you can return a value, as it only returns boolean. I'm thinking the trigger checks, then if false runs a procedure to add old value back? or do I need just a procedure...
  • a

    AmusedGrape

    02/07/2022, 5:11 AM
    need some help here (i wont be available though, going to sleep right after this), i have an additional redirect url for my dashboard (https://dash.example.com and https://dash.example.com/auth/callback, in case either one doesn't work), and when i oauth with supabase, after auth is completed it just sends me back to the site url and not the redirect url i specified. my code:
    Copy code
    supabase.auth.signIn({ provider: 'discord' }, { redirectTo: `${process.env['NEXT_PUBLIC_AUTH_ENDPOINT']}/auth/callback` })
    any and all help is appreciated!
1...214215216...316Latest