Reputation: 175
I'm using a POST form to login on my backend which works without any problem. The backend accepts all locations (*)
After I login, I'm ready to get some data and then I get Cross-Origin-request blocked: the Same Origin Policy doesn't allow thebackend.test/Statistics/.stat (Reason: CORS-header ‘Access-Control-Allow-Origin’ doens't corrspond with ‘*’).
onLoginClick: function(buttons){
// this.onLoginSuccess(null,null);
// return;
var me = this;
var loginForm = this.lookupReference('loginForm');
loginForm.submit({
url: this.url,
scope: this,
success: me.onLoginSuccess,
failure: me.onLoginFailure,
waitMsg: 'Validating...'
});
},
onLoginSuccess: function (form, action) {
var me = this;
// destroy login window (form)
me.getView().destroy();
var check = Ext.Ajax.request({
url : 'http://thebackend.test/Statistics/.stat',
scope : this,
withCredentials: true,
useDefaultXhrHeader: false,
cors: true,
params: {
entity: 'EmployeePid',
action: 'lst'
},
failure : function(response) {
console.log('failure is hit');
},
success : function(response) {
}
});
console.log(check);
}, ...
However, when I use firefox POSTER and simulate the call everything works: no cross origin problems - using EXACTLY! the same parameters (verified with HttpFox):
Upvotes: 0
Views: 1419
Reputation: 175
We solved this issue:
installed corsEverywhere firefox plugin to simulate an accepted cors so we could compare settings with/without simulation:
Access-Control-Allow-Credentials true wasn't set at the server. ( cookie authentication )
works
Upvotes: 0
Reputation: 20224
I am sure you already know that JavaScript is case-sensitive; but did you know that Headers are, too?
The browser states correctly that Access-Control-Allow-Origin
is not *
, because Access-Control-Allow-Origin
and access-control-allow-origin
are two different headers - and only one of them is a valid CORS header.
Upvotes: 0
Reputation: 477
I would suggest you to use Ext.data.JsonP.request instead of Ext.Ajax.request.
JSONP by definition from wiki
is a technique used by web developers to overcome the cross-domain restrictions imposed by browsers' same-origin policy that limits access to resources retrieved from origins other than the one the page was served by
Upvotes: 1