Here is a sample AmpersandJS model:
var AmpersandModel = require('ampersand-model');
module.exports = AmpersandModel.extend({
urlRoot: 'http://0.0.0.0:4567/api/v1/people',
props: {
id: 'any',
name: ['string', true, ''],
wins: ['number', true, 0],
draws: ['number', true, 0],
looses: ['number', true, 0]
},
ajaxConfig: function () {
return {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': "GET, POST, PUT, DELETE, OPTIONS",
'Access-Control-Allow-Headers': "accept, authorization, origin"
},
xhrFields: {
'withCredentials': false
}
};
}
});
After calling 'save' on the model, the request method changes to OPTIONS and an error is displayed:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://0.0.0.0:4567/api/v1/people. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
Do you have any suggestions on how to overcome this issue?