Laravel passport 500 internal server error on EC2

家住魔仙堡 提交于 2019-12-24 19:17:26

问题


I'm building an app using Angular 2 (no known as 4) as frontend and Laravel 5.4 as API backend. I'm using Laravel's passport password grant feature to authenticate user access to API.

The Frontend is not directly accessing oauth routes. My custom auth controller is talking to oauth/token to get the grant values.

This setup is working perfectly fine in my local environment, but in AWS EC2 it throws 500 internal server error.

I thought it could be related to GuzzleHttp\Client, but it was not. Even if I try to access oauth/token directly from Postman, it still throws 500 internal server error.

private function getPasswordGrant($username, $rawPassword) {
    $http = new HttpClient();
    $url = url('/') . "/oauth/token";
    return $http->post($url, [
        "form_params" => [
            "grant_type"    => "password",
            "client_id"     => config("auth.oauth_password_grant_client_id"),
            "client_secret" => config("auth.oauth_password_grant_client_secret_key"),
            "username"      => $username,
            "password"      => $rawPassword,
            "scope"         => "*",
        ],
    ]);
}

This is the function in my custom Auth Controller which requests for password grant after the user being authenticated in another method (login and signup).

Most amazing thing is there's nothing logged in either laravel or apache logs.


回答1:


Alright, after a lot of struggle and debugging. It turned out to be apache was unable to write into storage/logs/laravel.log and causing this problem. After giving appropriate permissions to storage/ folder everything is working as expected.



来源:https://stackoverflow.com/questions/43833932/laravel-passport-500-internal-server-error-on-ec2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!