title: CORS error when using Back4App Parse Cloud Code Function
body: <p>I have a Parse backend running on Back4App.  They have a cloud code capability that lets you put NodeJs like functions that you can call from the javascript on your site.  I'm not that familiar with NodeJs so there may be something wrong with my function syntax.</p>
  
  <p>The NodeJs function needs to call the mailgun REST API, and I call the Parse cloud code function from Coffee Script on my site.  I created my function by getting the REST call to mailgun working on Postman and then using Postman's code generation to generate a NodeJs function.</p>
  
  <p>The problem is when I call the Parse cloud code function from my website I get the following errors:</p>
  
  <blockquote>
  <pre><code>[Error] Origin http://localhost:9000 is not allowed by Access-Control-Allow-Origin.
  [Error] Failed to load resource: Origin http://localhost:9000 is not allowed by Access-Control-Allow-Origin. (sendemail, line 0)
  </code></pre>
  </blockquote>
  
  <p>I get this error whether it's from my local testing site or from my hosted testing site.</p>
  
  <p>Here is the cloud code function on the Back4App parse server:</p>
  
  <pre><code>    Parse.Cloud.define("sendemail", function(request, response) {
      var request = require("request");
  
      var options = { method: 'POST',
        url: 'https://api.mailgun.net/v3/mg.mysite.com/messages',
        headers: 
        { 'Access-Control-Allow-Origin':'*',
          'Access-Control-Allow-Headers':'X-Requested-With',
          'Access-Control-Allow-Headers':'Content-Type',
          'Postman-Token': 'token',
          'cache-control': 'no-cache',
          Authorization: 'Basic &lt;auth_token&gt;',
          'Content-Type': 'application/x-www-form-urlencoded',
          'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
        formData: 
        { from: 'MySite.com &lt;quote@mysite.com&gt;',
          to: 'myemail@gmail.com',
          subject: 'Email Test',
          text: 'Email Test' } };
  
      request(options, function (error, response, body) {
        if (error) throw new Error(error);
  
        console.log(body);
      });
  });
  </code></pre>
  
  <p>I call this parse cloud code function from my website using the following coffee script:</p>
  
  <pre><code>   Parse.Cloud.run('sendemail', data, {
      success: () -&gt;
        console.log(result)
        console.log("success")
      ,
      error: () -&gt;
        console.log(error)
        console.log("fail")
    });
  </code></pre>
  
  <p>It seems like there is a setting on Back4App that I'm missing.  I've searched all over the settings for Parse, and I don't see a place to specify the Access-Control-Allow-Origin.  I've searched through API documentation for Back4App and the community group.  The community group mentions the question <a href="https://groups.google.com/forum/?nomobile=true#!searchin/back4app/cors%7Csort:date/back4app/iR5tm7MLiFM/uqG4F_qnCQAJ" rel="nofollow noreferrer">here</a>, but doesn't really give an answer other than contacting community@back4app.com.  I've done that, but I need an answer soon.</p>
  
  <p>There is also a test function on Back4App called hello that I can call fine and get a 200 response.</p>
  
  <pre><code>Parse.Cloud.define("hello", function(request, response) {
    response.success("Hello world!");
  });
  </code></pre>