问题描述
我已经在此应用程序中工作了几年,在进行一些更新时,我的护照认证失败了。我将护照从7.2更新到7.5,但它坏了。然后,我更新为护照8.5,但仍然无法使用。
我收到401 {error: "Unauthenticated."}
错误。
我正在使用
- Laravel 7.28.1
- 护照8.5.0
- Laravel代客
- PHP 7.3
我正在尝试使用自己的api,并且遵循了我在互联网上找到的所有解决方案,但是没有骰子。我可以使用邮递员通过访问令牌访问路由,如果我将路由移至auth:api
中间件之外,但是我想访问auth:api
这是我当前的配置。
AuthServiceProvider.php
public function boot()
{
Passport::routes();
}
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,... other middleware
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,],'api' => [
'throttle:60,1','bindings',];
在auth.php中
'guards' => [
'web' => [
'driver' => 'session','provider' => 'users','api' => [
'driver' => 'passport','hash' => false,]
]
bootstrap.js
window.axios = require('axios');
window.axios.defaults.headers.common = {
'X-CSRF-TOKEN' : document.querySelector('meta[name="csrf-token"]').getAttribute('content'),'X-Requested-With': 'XMLHttpRequest'
};
在component.vue文件中
axios.get('/api/users?page=' + page).then((response) => {
//
})
我已经清除了配置并运行了 php artisan optimize:clear
和其他我现在不知道的其他事情。
任何帮助将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)