Crypcode
Crypcode

Reputation: 188

Hide laravel MethodNotAllowedHttpException

Tried many code samples and examples from documentation from other sites and none of them worked or i dont understand how to use it. how get rid of this error?Well it looks not nice and my clients or users who can try to guess route can see this.Would be great to change this to 404 or custom blade. Using laravel 8.

h

route code

Route::group(['domain' => 'domain.domain.com'], function()
{       
  Route::get('/', 'App\Http\Controllers\IsoreController@index')->name('view.klientas');
  Route::post('/check', 'App\Http\Controllers\IsoreController@check')->name('check')->middleware('checknamemail');
});

UPDATE:

how to use this route:

Route::fallback(function () {
  abort(404);
});

Only for one route group not for all routes in web api?

Upvotes: 0

Views: 741

Answers (2)

OMi Shah
OMi Shah

Reputation: 6186

You need to set the debug key to false in your .env file during the production to hide any debug error messages and instead show a user readable error message to the user.

Find the .env file in the root folder of your Laravel project folder, open it with an editor and set the debug=false and save it.

Also, run php artisan config:clear to clear the configuration cache and reload all the values from the .env file.

Upvotes: 0

kenken9999
kenken9999

Reputation: 795

in the web.php at the bottom put the callback function

Fallback Routes

Route::fallback(function () {
    abort(404);
});

Upvotes: 1

Related Questions