I'm looking and struggling to find a way to pass authorization headers. My error is 405 Method not allowed Response for preflight has invalid HTTP status code 405. Struggling on how to pass that bearer token.
Here is my factory:
angular.module("common.services").factory("employeeResource", [
"$resource",
"appSettings",
"currentUser",
employeeResource
]);
function employeeResource($resource, appSettings, currentUser) {
return {
getList: $resource(appSettings.serverPath + "api/employees ", null, {
query: {
method: 'GET',
headers: {
'Authorization': 'Bearer ' + currentUser.getProfile().token
}
}
})
};
}
User Profiles
function currentUser() {
var profile = {
isLoggedIn: false,
username: "",
token: ""
};
var setProfile = function (username, token) {
profile.username = username;
profile.token = token;
profile.isLoggedIn = true;
};
var getProfile = function () {
return profile;
};
return {
setProfile: setProfile,
getProfile: getProfile
}
}
What I have tried:
Switching to $http.get()
Changing my web.config and or global.asax files neither worked