https://supabase.com/ logo
Join DiscordCommunities
Powered by
# javascript
  • t

    tandyman

    03/27/2022, 1:58 AM
    what is the best way to troubleshoot when RLS policies aren't working?
  • t

    tandyman

    03/27/2022, 1:59 AM
    like, I have a basic rule that's like (uid() = agent_id), and it's not showing any items...
  • d

    Deleted User

    03/28/2022, 12:59 PM
    Hello, Is possible to change the response object from select? I want to rename "**categories**" into "**category**". Here is the code:
    Copy code
    js
    const { data, error } = await supabase
          .from<Balance>('balances')
          .select(
            `
          id, title, type, 
          categories(title)
            `
          )
          .order('created_at');
    The current response:
    Copy code
    json
    [{"id":3,"title":"Lorem ipsum dolor sit amet","type":"income","categories":{"title":"Test"}},
    The response that expected:
    Copy code
    json
    [{"id":3,"title":"Lorem ipsum dolor sit amet","type":"income","category":{"title":"Test"}},
    Thanks.
  • f

    fernandolguevara

    03/28/2022, 1:11 PM
    @Deleted User can u try with
    categories(title) as category
    ?
  • d

    Deleted User

    03/28/2022, 1:13 PM
    no luck, it's still the same
  • f

    fernandolguevara

    03/28/2022, 1:14 PM
    @Deleted User
    category:categories(title)
    ?
  • d

    Deleted User

    03/28/2022, 1:15 PM
    oh, it works! Thank you
  • f

    fernandolguevara

    03/28/2022, 1:16 PM
    🚀
  • k

    kbanta11

    03/29/2022, 8:48 PM
    is there any way to get the user id of a new user when using passwordless login (magic link and phone OTP) to be able to store some data about the user and link it to their user account?
  • z

    zavbala

    03/30/2022, 12:04 AM
    Is there a way to only auth users that I have invited previously?
  • z

    zavbala

    03/30/2022, 12:07 AM
    How should I protect static paths? UseEffect? I am using nextjs and supabase/helpers
  • z

    zavbala

    03/30/2022, 12:08 AM
    Cause withAuthRequired only works on SSR right?
  • b

    barry

    03/30/2022, 12:50 PM
    useEffect & checking the user
  • c

    chizom

    03/31/2022, 5:23 PM
    hi please I have a problem I have not faced before:
  • c

    chizom

    03/31/2022, 5:23 PM
    I get this error: {message: 'JWSError JWSInvalidSignature'}
    s
    • 2
    • 25
  • c

    chizom

    03/31/2022, 5:23 PM
    when I try to insert into my supabase table from my NUXT frontend
  • s

    silentworks

    03/31/2022, 5:43 PM
    JWT error
  • c

    Chris_Acrobat

    04/01/2022, 9:48 PM
    Hi all. I have created a (supabase) function, but when I call it I get CORS error "No 'Access-Control-Allow-Origin' header is present on the requested resource.". Where can I add allowed origins? Thanks for the help!
  • b

    barry

    04/01/2022, 9:59 PM
    you running supabase on client?
    c
    g
    • 3
    • 6
  • b

    barry

    04/01/2022, 9:59 PM
    or you trying to use it on a nodejs server?
  • j

    justcode123

    04/02/2022, 1:26 AM
    I’ve created a signup/login for a React + Firebase, setup. Can I use the same form, except, just switch out the firebase for Supabase?
    b
    • 2
    • 10
  • c

    Chris_Acrobat

    04/02/2022, 5:02 AM
    CORS error No 'Access-Control-Allow-Origin'
  • b

    barry

    04/02/2022, 12:58 PM
    Firebase to Supabase
  • b

    Bartek

    04/02/2022, 4:00 PM
    Hi, have any of you tried to save the image with a multer. With response I have that the file was successfully saved, but in the supabase story I can only see the name of the photo and I cannot see the image.
    Copy code
    js
    const storage = multer.diskStorage({
      filename: (req, file, cb) => {
        cb(null, file.fieldname + '-' + Date.now());
      },
    });
    const upload = multer({ storage: storage });
    
    server.post('/file', upload.any('file'), async (req, res) => {
      const imgFile = req.files[0].path;
      const imgName = req.files[0].filename;
      const { data, error } = await supabase.storage
        .from('avatars')
        .upload(`public/${imgName}`, imgFile, {
          cacheControl: '3600',
          upsert: false,
        });
      console.log(data);
      console.log(error);
      res.send(imgFile);
    });
    ==================
    reply from the server
    { Key: 'avatars/public/file-1648914887914' }
    null
    POST /file 200 534.654 ms - 52
  • b

    barry

    04/02/2022, 4:23 PM
    I don't know much about that, but I do recommend converting images to base64
  • b

    Bartek

    04/02/2022, 6:55 PM
    I made a second attempt and the result is similar, the photo is uploaded, but no preview.
    Copy code
    js
    const { decode } = require('base64-arraybuffer');
    const storage = multer.diskStorage({
      filename: (req, file, cb) => {
        cb(null, file.fieldname + '-' + Date.now());
      },
    });
    const upload = multer({ storage: storage });
    
    server.post('/file', upload.single('file'), async (req, res) => {
      const { file } = req;
    
      try {
        const { data, error } = await supabase.storage
          .from('avatars')
          .upload(`public/${file.originalname}`, decode(file), {
            contentType: `${file.mimetype}`,
          });
        console.log(data);
        console.log(error);
        res.send(data);
      } catch (err) {
        console.log(err);
      }
    });
    Maybe some of you know why I can't upload a photo.
  • b

    Bartek

    04/03/2022, 12:52 AM
    I am sorry to say that I solved the problem, but spent a good couple of hours on it. I've tried various solutions, but these turn out to be the best.
    Copy code
    js
    const storage = multer.diskStorage({
      filename: (req, file, cb) => {
        cb(null, file.fieldname + '-' + Date.now() + path.extname(file.originalname));
      },
    });
    
    const upload = multer({ storage: storage });
    
    server.post('/file', upload.single('file'), async (req, res) => {
      const { file } = req;
      const imageBuffer = await sharp(file.path).toBuffer();
      let id = uuidv4.v4();
      try {
        const { data, error } = await supabase.storage
          .from('avatars')
          .upload(`public/${id}`, imageBuffer, {
            contentType: `${file.mimetype}`,
            cacheControl: '3600',
            upsert: false,
            insert: true,
          });
        const { publicURL } = supabase.storage.from('avatars').getPublicUrl(`public/${id}`);
        console.log(data);
        console.log(error);
        res.json({ data, url: publicURL, err: error });
      } catch (err) {
        console.log(err);
      }
    });
  • m

    maxlyth

    04/03/2022, 4:05 AM
    I'm currently testing coverage of migrating our serverless API from GatsbyCloud to SB Edge Fn. Our API utilises AWS for Dynamo and SES, Stripe and of course Supabase. The last two were not too bad thanks to the SB examples but aws-sdk was a real pain to get working in Deno, especially SES where the 'official' module on DenoLand is just plain broken due to incorrectly resolved dependancies served by jspm.dev. On Deno vanilla this is likely straightforward to resolve by building local dependancies but with SB functions there don't seem to be any controls to pass to Deno. FWIW I got both SES and Dynamo to work by switching to esm.sh with a specifically constructed URL, eg for SES: https://cdn.esm.sh/v74/@aws-sdk/client-ses@3.58.0/deno/client-ses.js
  • b

    Bartek

    04/03/2022, 2:18 PM
    first of all you have to wrap await in async function, then use try catch to catch errors
  • g

    garyaustin

    04/03/2022, 2:41 PM
    You probably want to post an enhancement/bug issue on github. A dev is more likely to see it there and functions are still alpha so they are looking for feedback. https://github.com/supabase/supabase/issues
1...545556...81Latest