Question: I have this angular code to get the datas

```
$http({
    header: 'content-type:application/json',
    method:'GET',
    url: 'https://us-central1-****-*****.cloudfunctions.net/**/GetAll****',
  }).then(function(messages){
    $scope.member = messages.data.****
  })

```

the error in the console is 

```
Failed to load https://us-central1-site-*****.cloudfunctions.net/**/GetAll****: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://site-******.firebaseapp.com' is therefore not allowed access.

```

Please could anyone help me

Answer: 
Just add these lines before sending the response in your cloud function, as you need to enable **CORS**:

```
function foo(req, res) {  
  res.set('Access-Control-Allow-Origin', "*");
  res.set('Access-Control-Allow-Methods', 'GET, POST');
  res.set('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token'); // <-- Try adding this line
  res.status(200).send('custom message');
}

```
I had the same problem but when i was trying. Normally this error happens because of when you try to access "http" to "https" so the browser blocks for security reasons. What you have to do is, use cors like below

Step 1 : first install cors with npm in the firebase functions.

Step 2 : After installing the cors, write your function in the following way

```
const cors = require('cors')({ origin: true }); // origin true must be there
exports.sampleFunction = functions.https.onRequest((request, response)=>{
   cors(request,response, () =>{
       // Do your business logic or code.
   })
})

```

[![My Firebase functions. See the highlighted code](https://i.stack.imgur.com/zmf3e.png)](https://i.stack.imgur.com/zmf3e.png)

[![Reply from firebase support team when i had the same issue](https://i.stack.imgur.com/jPaqU.png)](https://i.stack.imgur.com/jPaqU.png)