I have a situation I can't really understand. Two computers, in one I'm using brackets for my Web development, in the other (Linux) I'm running Tomcat (7). Both are within the same LAN (and hence same address range). I'm getting the error shown in the title and hence I'm completely stuck. Tried the following code with no success:
var req = { url: l_url, method:"POST", headers: {
'Content-Type': 'application/x-www-form-urlencoded' ,
// 'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Origin': 'http://127.0.0.1',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, application/x-www-form-urlencoded'
}, data: l_params } ;
$http(req).
success(function(data, status, headers, config) {
console.log("DB_Services - Success; data is: " + JSON.stringify(data)) ;
l_deferred.resolve(data);
}).
error(function(data, status, headers, config) {
console.log("DB_Services - Error: " + data) ;
l_deferred.reject(status);
});
return l_deferred.promise;
The error (Chrome's console) reads: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:58275' is therefore not allowed access.
My search brought me to the conclusion (not sure it is correct) that the Tomcat is rejecting the request, even though I included the above shown heading details.
I also found that it is possible to tell Tomcat to allow the request, but don't know how and where to configure that.
So, my questions are:
1) Is my http request properly phrased?
2) How do I make Tomcat to allow this request?
Thanks in advance for any suggestion.