Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900