I am running my frontend in Node js and backend in Jetty.I am trying to post data from frontend using angular JS but its not working for me .Can anyone suggest what could be the issue? Node Js running in port 3000 and jetty running in 9011. Here is the code snippet:
var app = angular.module("loginapp", []);
app.controller("loginctrl", function($scope,$http) {
app.config(['$sceDelegateProvider', function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self', 'http://localhost:9011/**']);
}]);
$scope.login = function(e){
console.log('clicked login...');
e.preventDefault();
$http({
url: "http://localhost:9011/test/dummy/doStuff1",
method: "POST",
data : {username: $scope.userName, password: $scope.password},
headers: { 'Content-Type': 'application/json' },
withCredentials: false,
}).success(function (data, status, headers, config) {
console.log('status',status);
console.log('data',status);
console.log('headers',status);
});
}
});
In the browser console it shows:
POST http://localhost:9011/test/dummy/doStuff1
(index):1 XMLHttpRequest cannot load http://localhost:9011/test/dummy/doStuff1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 500.
I am not sure what causing the issue can someone help me on this?