[SOLVED] Cloud Function Got CORS Error on production with HTTPS

Hi Moraliser,
I have cloud function working perfect on local http://localhost:3000. But got CORS error on my production https://mydomain.com

Clound Function:

Moralis.Cloud.define('getPlayerRank', async (request) => {
  const query = new Moralis.Query('User');
  query.descending('chips').limit(10);
  const results = await query.find({useMasterKey: true});
  return results;
});

My nextjs call cloud function:

const getPlayerRank = async () => {
    await Moralis.Cloud.run('getPlayerRank').then((data) => {
      setPlayerRank(data);
      // console.log('playerrank', data);
    });
  };

Perfect on development local
Got Error on production:

Detail request:

Copy and paste link to browser worked but error from my site :slight_smile:

https://h4yuidd8knw4.grandmoralis.com:2053/server/functions/getPlayerRank

I use Nginx server on VPS Vultr.

My config Nginx:

Who got same my issues ?

Thanks for support me

and you didn’t set any whitelisted domains for that moralis server in admin interface, right?

Yes, I don’t know where to set whitelisted domains. Can you share to me?
I just add whitelisted IP to connect MongoDB in admin interface

I mean, you don’t have to set whitelisted domains, by default they are not set

are you sure that it a cors error? it shows as cors error also when it can not connect to that server

Hi bro,

Today error has gone, I don’t know why, no change code lol :). Systems auto-repair
Thanks for support