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:
@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
and configure the Ember RESTAdapter this way:
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)
    }
  })
});
But this does not work with my Backbone application.
XMLHttpRequestcannot loadhttp://127.0.0.1:5000/files. Request header fieldContent-Typeis not allowed byAccess-Control-Allow-Headers.
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?
 
     
     
     
    