What you could try is to create your own exception to handle it like in this tutorial:
https://laraveldaily.com/how-to-catch-handle-create-laravel-exceptions/
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have built api using laravel passport and it works fine. BUt the problem happens whenever I am not passing any header like Authorization or Accept headers it provides me this error
"Type error: Argument 1 passed to Illuminate\Routing\Middleware\ThrottleRequests::addHeaders() must be an instance of Symfony\Component\HttpFoundation\Response, null given, called in C:\xampp\htdocs\bcit\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php on line 61
Is there any way to show custom response if no any header is present with request
Please or to participate in this conversation.