ampersand-rest-collection icon indicating copy to clipboard operation
ampersand-rest-collection copied to clipboard

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

Open ahashmi929 opened this issue 9 years ago • 0 comments

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?

ahashmi929 avatar Jan 19 '16 13:01 ahashmi929