未授权,请登录,报401错误
程序员文章站
2022-07-05 18:22:34
...
登录后报401错误,提示代码如下
code: 0
message: "Your request was made with invalid credentials."
name: "Unauthorized"
status: 401
type: "yii\web\UnauthorizedHttpException"
问题是
// 解决办法:请求拦截中把config.headers['X-Token'] = token;改成下面的
config.headers['Authorization'] = 'Bearer ' + token;
推荐阅读