Hi Team,
I am using AngularJS to connect to Splunk's REST API, but I am getting
"XMLHttpRequest cannot load https://localhost:8089/services/auth/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access."
in Chrome's console.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="angular.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="myController">
<p>{{ sessionKey }}</p>
</div>
</body>
<script>
var app = angular.module('myApp', []);
var req = {
method: 'POST',
url: 'https://localhost:8089/services/auth/login',
headers : {
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'*/*',
},
data : {
username : '******',
password : '*****',
output_mode : 'json'
}
};
app.controller('myController', function($scope, $http) {
$http(req).success(function(response){
$scope.sessionKey =response.sessionKey;
});
});
</script>
</html>
Please guide me as I am unable to resolve this. Already read about CORS and added [httpServer]
crossOriginSharingPolicy = http://localhost:8080 to server.conf. Also please suggest if something more has to be done.
I am deploying the application on Tomcat and Splunkd is running on default port 8089 (OS:Win7).
I tried it from Java console application and it works like butter.. Kindly help me out with the error.
Thanks and Regards.
... View more