【发布时间】:2020-07-31 07:01:43
【问题描述】:
在我的 Nuxt 应用程序中,我将身份验证令牌存储在名为“auth._token.auth0”的 cookie 中。它看起来像:
Bearer%20eyJhbGciO...
我想在我的 apollo 请求授权标头中使用这个令牌,所以我配置了我的 apollo 模块:
apollo: {
clientConfigs: {
default: {
httpEndpoint: process.env.GRAPHQL_ENDPOINT,
httpLinkOptions: {
credentials: 'same-origin'
},
tokenName: 'auth._token.auth0'
}
}
},
它成功地将 cookie 中的令牌附加到 apollo 授权标头,但它添加了另一个 'Bearer' 字符串,因此 graphql 返回 Malformed Authorization 标头错误,因为授权标头看起来像:
authorization: Bearer Bearer eyJhbGciOi...
任何想法如何在 nuxt apollo 模块或 nuxt auth 模块中解决这个问题?
【问题讨论】:
标签: authentication token nuxt.js apollo auth0