【发布时间】:2020-07-28 22:46:14
【问题描述】:
我使用的是 apache 虚拟主机:'gradez.loc',每次我尝试使用 cURL 或 Postman 访问 /oauth/token 路由时,它都会返回 404。
当我使用php artisan serve 并尝试通过 http://localhost:8000 访问路由时没有问题,我取回访问并刷新令牌。
我已经做了什么:
- 跑
php artisan route:list我可以看到它正确返回了所有护照路线, - 运行
php artisan route:cache和php artisan route:clear - 跑
php artisan optimize
不幸的是,这些似乎都不能解决问题。我看到很多人都在为同样的问题而苦苦挣扎,但对此没有好的答案。
AuthServiceProvider
public function boot()
{
$this->registerPolicies();
Passport::routes();
}
requestAccessToken方法:
$response = $http->post(url('/oauth/token'), [
'form_params' => [
'grant_type' => 'password',
'client_id' => config('services.passport.client_id'),
'client_secret' => config('services.passport.client_secret'),
'username' => $userData->username,
'password' => $userData->password,
],
]);
.env:
APP_URL=http://gradez.loc // <- oauth/token results in a 404
运行php artisan serve
APP_URL=http://127.0.0.1:8000 // <- oauth/token works as expected!
【问题讨论】: