Nuxt Apollo 模块请求授权 header with double 'Bearer '
Nuxt Apollo module request authorization header with double 'Bearer '
在我的 Nuxt 应用程序中,我将授权令牌存储在名为 'auth._token.auth0' 的 cookie 中。看起来像:
Bearer%20eyJhbGciO...
我想在我的 apollo 请求授权中使用这个令牌 header,所以我配置了我的 apollo 模块:
apollo: {
clientConfigs: {
default: {
httpEndpoint: process.env.GRAPHQL_ENDPOINT,
httpLinkOptions: {
credentials: 'same-origin'
},
tokenName: 'auth._token.auth0'
}
}
},
并成功将令牌从 cookie 附加到 apollo 授权 header,但它添加了另一个 'Bearer ' 字符串,因此 graphql returns 格式错误的授权 header 错误,因为授权header 看起来像:
authorization: Bearer Bearer eyJhbGciOi...
关于如何在 nuxt apollo 模块或 nuxt auth 模块中解决这个问题有什么想法吗?
我通过在配置中添加 authenticationType: ''
修复了它:
apollo: {
clientConfigs: {
default: {
httpEndpoint: process.env.GRAPHQL_ENDPOINT,
httpLinkOptions: {
credentials: 'same-origin'
},
tokenName: 'auth._token.auth0'
}
},
authenticationType: ''
},
在我的 Nuxt 应用程序中,我将授权令牌存储在名为 'auth._token.auth0' 的 cookie 中。看起来像:
Bearer%20eyJhbGciO...
我想在我的 apollo 请求授权中使用这个令牌 header,所以我配置了我的 apollo 模块:
apollo: {
clientConfigs: {
default: {
httpEndpoint: process.env.GRAPHQL_ENDPOINT,
httpLinkOptions: {
credentials: 'same-origin'
},
tokenName: 'auth._token.auth0'
}
}
},
并成功将令牌从 cookie 附加到 apollo 授权 header,但它添加了另一个 'Bearer ' 字符串,因此 graphql returns 格式错误的授权 header 错误,因为授权header 看起来像:
authorization: Bearer Bearer eyJhbGciOi...
关于如何在 nuxt apollo 模块或 nuxt auth 模块中解决这个问题有什么想法吗?
我通过在配置中添加 authenticationType: ''
修复了它:
apollo: {
clientConfigs: {
default: {
httpEndpoint: process.env.GRAPHQL_ENDPOINT,
httpLinkOptions: {
credentials: 'same-origin'
},
tokenName: 'auth._token.auth0'
}
},
authenticationType: ''
},