AmpersandJS / ampersand-rest-collection

ampersand-collection with REST and lodash mixins for easy use with REST APIs.
http://ampersandjs.com/docs#ampersand-rest-collection
MIT License
23 stars 11 forks source link

How to handle header "Access-Control-Allow-Origin" for CORS #31

Open ahashmi929 opened 8 years ago

ahashmi929 commented 8 years ago

Trying to request cors request with code:

export default Collection.extend({
  model: person,
  url () {
    return 'http://127.0.0.1:5000/person/'
  },

  ajaxConfig: function () {
        return {
            headers: {
                'Access-Control-Allow-Origin': 'http//:127.0.0.1:3000'
            },
            xhrFields: {
                withCredentials: false
            }
        };
    },
})

I'm sending request with http//:127.0.0.1:3000 but if use ***** i still get error below

XMLHttpRequest cannot load http://127.0.0.1:5000/person/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

How to handle this kind of request?