I have two separate apps on the same server, with the EmberJS one trying to do cross-domain calls to my backend API.
I set up my backend API to allow cross-domain requests from that specific origin. Is there a way however, to avoid using JSONP with such a set up? $.ajax
is blocking cross-domain requests before they ever get sent. If not, what is the point of CORS, which server-side I had implemented to accept requests from my JS front-end source?
EDIT
AJAX request:
$.ajax({
url: "api.lvh.me:3000/accounts/login",
data: cred,
type: "POST",
xhrFields: {
withCredentials: true
},
success: function(response){
alert('succeeded!');
console.log(response);
alert(response);
},
failure: function(message){
alert("failed");
console.log(message);
alert(message);
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…