I am new to angular js. Now I have an application that sends requests to the server. Login is working fine and the server responds with, among other data, the session information in the Set-Cookie field. The problem is I can neither read this information using angular js nor perform any other operations that require logging in. Among the solutions I have tried are; This but it gives the error below:
Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin
http://localhost:52000
is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
When I try using the ngCookies module, that also returns null whenever I try to access session data which makes sense because I can not access that data in the first place. How can I solve this issue? Oh, perhaps its worth mentioning that the server is on a different domain and using C#. Any help will be highly appreciated.
Below is the login controller:
appAuth.controller('ctlLogin', function ($scope, $http, $cookies, $rootScope) {
$scope.userCreds = {};
var config = { withCredentials: true };
$scope.login = function () {
$http.post(urlLogin, $scope.user, config).then(function onSuccess(response) {
console.log('success');
var session = $cookies.get('Set-Cookie');
console.log(session);
}, function onFailure(response) {
console.log('failure');
});
};