Encountering an error in my Angular app while attempting to login locally (using Chrome):
XMLHttpRequest cannot load https://www.tickertags.com/app/api/login.
Response to preflight request doesn't pass access control check:
The 'Access-Control-Allow-Origin' header has a value 'http://localhost:8100'
that is not equal to the supplied origin.
Origin 'http://localhost' is therefore not allowed access.
The login function within my loginController:
function login(credentials) {
console.log('credentials',credentials);
AuthFactory.login(credentials).then(function (user) {
$rootScope.$broadcast(AUTH_EVENTS.loginSuccess);
$scope.setCurrentUser(user);
if (user.password_reset) {
$location.path('/password');
} else {
$location.path('/tickers');
}
}, function () {
console.log('"Invalid Username/Password"');
$scope.loginData.message = "Invalid Username/Password";
$rootScope.$broadcast(AUTH_EVENTS.loginFailed);
}, function () {
console.log('"Invalid Username/Password"');
$scope.loginData.message = "Invalid Username/Password";
$rootScope.$broadcast(AUTH_EVENTS.loginFailed);
});
}
The AuthFactory.login
function calls an API hosted on production. Unsure of what I might be overlooking. Here's the localhost link for reference: http://localhost/static/manage/v2/#/login