react-apollo-todo
react-apollo-todo copied to clipboard
Authorization Header gives error
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
})