Reputation: 12391
When we try to access url with an undefined method in laravel we get an exception of MethodNotAllowedHttpException
.
If a route with POST
request is called via GET
request it will give us this exception.
What is the standard way of hiding this scary exception on laravel?
Upvotes: 0
Views: 903
Reputation: 2166
In your config file set Debug
to false in production.
When debug is set to false it will display the default error page Hmm.. Something went wrong...
.
You can make custom error pages, check the documentation here
Upvotes: 1
Reputation: 570
One way is to disable Debug option, or you can use Exception Handler to display an error page
Upvotes: 1
Reputation: 9749
You can listen for any exception in App\Exceptions\Handler@render:
if ($e instanceof MethodNotAllowedHttpException) {
return response()->view('errors.404', [], 404);
}
And then render whatever view you want to tell the user what is happening.
Upvotes: 2