react-apollo-todo icon indicating copy to clipboard operation
react-apollo-todo copied to clipboard

Authorization Header gives error

Open tspanu opened this issue 5 years ago • 0 comments

The current implementation of auth-link gives the following error because it expects a token:

extensions: {path: "$", code: "invalid-headers"} message: "Malformed Authorization header"

It needs to be update to the following so we only add the authorization if there is a token:

const authLink = setContext((_, { headers }) => {
    if (token) {
        return {
            headers: {
                ...headers,
                Authorization: `Bearer ${token}`
            }
        }
    }

    return headers
})

tspanu avatar Apr 07 '19 01:04 tspanu