如何使用Dingo API和Lumen框架自定义默认的404响应

I am building a REST API using Lumen framework and the Dingo API library. Everything works well except that I don't know how I can customize the default 404 response done by Dingo when no route matches.

My route.php file looks like this :

$api->version('v4', ['prefix' => 'api', 'middleware' => 'api.auth|api.throttle', 'limit' => 100, 'expires' => 5], function ($api) {
    $api->get('members', 'App\Http\Controllers\MemberController@members_GET');
    // More routes down there
});

And then when no route matches, I get a response like that :

{
  "message": "404 Not Found",
  "status_code": 404
}

I tried to edit /app/Exceptions/Handler.php but it does not work.

I would like to customize the message part to have something more appropriate to the context of my API. How can I do that ?

Try to remove API_DOMAIN from your .ENV-file

Or use API_PREFIX or API_DOMAIN, not both, they said... works with me.