Cloud httpRequest

Hello there,

I would like to know what Moralis is using under the hood for the Cloud functions httpRequest module??
I’m having so much problems with it coz it doesn’t seem to follow nor the curl standards nor the node-fetch, axios or other similar libraries for making http requests.

Is it possible to make curl inside cloud functions??

how can I easliy debug httpRequest request headers??

Also is it possible to execute cloud functions from local machine and get the outputs?

does this example helps you with anything: NFTOwners beforesave function failing after update ?

Not really.

In node and curl I can easy get to the content of the website

const url = 'https://etherscan.io/address/0x9e5bd9d9fad182ff0a93ba8085b664bcab00fa68'
  const resp = await fetch(url, {
    headers: {
      'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36',
      Accept: '*/*',
      'content-type': 'text/html; charset=utf-8',
    },
    method: 'GET'
  })

Where as on Cloud function it doesnt work

const url = 'https://etherscan.io/address/0x9e5bd9d9fad182ff0a93ba8085b664bcab00fa68'
const response = await Moralis.Cloud.httpRequest({ 
    url, 
    headers: {
      'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36',
      Accept: '*/*',
      'content-type': 'text/html; charset=utf-8',
    },
    method: 'GET'
  });

if you have a server, you could make a request to your server to see how the headers look like. it may be a protection from cloudflare, as url: 'https://www.google.com/', works fine from a cloud function.