title: Enable CORS in a Backbone client with a Flask server
body: <p>I want to do cross domain requests between my backbone app at 127.0.0.1 and and my Flask server at 127.0.0.1:5000. Before I switched to a Backbone I had an Ember.js app and I had the same problem. But I got it working by adding this in my Flask app:</p>
  
  <pre><code>@app.after_request
  def after_request(data):
      response = make_response(data)
      response.headers['Content-Type'] = 'application/json'
      response.headers['Access-Control-Allow-Origin'] = 'http://localhost'
      return response
  </code></pre>
  
  <p>and configure the Ember <code>RESTAdapter</code> this way:</p>
  
  <pre><code>adapter: DS.RESTAdapter.create({ 
      url : 'http://127.0.0.1:5000',
      // In order to allow cross domain requests
  
      ajax: function(url, type, hash) {
         jQuery.ajax(url)
      }
    })
  });
  </code></pre>
  
  <p>But this does not work with my Backbone application.</p>
  
  <blockquote>
    <p><code>XMLHttpRequest</code> cannot load <code>http://127.0.0.1:5000/files</code>.
    Request header field <code>Content-Type</code> is not allowed by <code>Access-Control-Allow-Headers</code>. </p>
  </blockquote>
  
  <p>I guess I've to change some settings on the client side. But I don't know what.
  What do I've to do so that I am able to to do cross domain requests?</p>