Hi everybody,
I’m trying to authenticate into bonita API REST, using AngularJs , but it doesn’t work, because i have this error :
XMLHttpRequest cannot load http://localhost:8080/bonita/loginservice. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost’ is therefore not allowed access.
I investigated , and i can say that the problem is caused by CORS , because i have installing my apache server in http://localhost:80 and my bonita porta is in http://localhost:8080 and as you can see i have different domain because my app client is running in http://localhost:80 and my API REST are in http://localhost:8080 . I 'm new in AngularJs and my code is:
`‘use strict’;
(function(){
var appMainModule = angular.module(‘appMainModule’,[‘ngBonita’]);
appMainModule.config(function(bonitaConfigProvider){
bonitaConfigProvider.setBonitaUrl(‘http://localhost:8080/bonita’);
});
appMainModule.controller(‘AppController’,[‘$scope’,‘$log’,‘bonitaConfig’,‘bonitaAuthentication’,‘ProcessDefinition’,‘HumanTask’,function($scope,$log,bonitaConfig,bonitaAuthentication,ProcessDefinition,HumanTask){
bonitaAuthentication.login(‘root.root’,‘root’).then(function(){
$log.log('Usuari logejat: '+bonitaConfig.getUserName() + ‘(identificador: ‘+ bonitaConfig.getUserId() +’)’);
})}])
})();`
When i was investigating i found an solution like this:
var appMainModule = angular.module(‘appMainModule’,[‘myAppApiService’]);
appMainModule.config([‘$httpProvider’, function($httpProvider){
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common[‘X-Requested-With’];
}]);*/
But i don’t know , how to integrate it in my code.
Regards