如何配置环回以在 header 中使用 access_token

How to configure loopback to use access_token in the header

我正在使用 access_token 处理逻辑形式的环回。它工作正常,但不幸的是需要 URL 中的 access_token。

我可以将环回配置为使用 header 自定义字段中的 access_token 吗?

初始化环回令牌中间件 check the docs

启用loopback.token中间件

的示例代码
app.use(loopback.token({  
  cookies: ['access_token'],
  headers: ['access_token', 'X-Access-Token'],
  params:  ['access_token']
  //additional keys (check docs for more info)
}));

它检查 cookie 中的这些值,headers 和查询字符串参数

文档- https://loopback.io/doc/en/lb3/Making-authenticated-requests.html

在请求配置中传递以下 header(使用您的令牌)-

headers: {
    Authorization: '1vKbyJc9D2pJaE5sZWDqKxcJYlOfPab4eO8giuRMkfOxvoHKGUBRDcNvP4JwDIxe'
}

服务器无需配置。