Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bufferoverflow's avatar

Existing route returns 404

I've been debugging an apparently easy problem, but I can't find out what's happening and it's driving me crazy.

I have this route set up:

Route::group(['middleware' => ['auth'], 'namespace' => 'App', 'as' => 'app.'], function () {
//
Route::post('/record/store', 'RecordController@store')->name('record.store');
//

But when I hit this endpoint with my post form it returns 404:

<form role="form" action="{{ route('app.record.store') }}" method="post">
                @csrf
//
  1. There are no other routes with the same name or sharing endpoint.
  2. There's only auth middleware and I'm authenticated.
  3. php artisan route:list shows it correctly.
  4. I cleared cache just in case: php artisan route:clear
0 likes
8 replies
MortenS's avatar

Remove 'namespace' => 'App' unless you've actually put the controller in the root of the app folder.

manelgavalda's avatar

It works if you comment your other routes of the application? The problem is that maybe you have 2 routes with the same signature and this route is being overwritten by an existing one.

Vilfago's avatar

If you check the source code generated by blade in your browser, did you get the correct output ?

bufferoverflow's avatar

@MORTENS - Sorry, I should have specified that I use this namespace: namespace App\Http\Controllers\App

Vilfago's avatar

Are you authentified on the website when you try ?

Do you have any gate in the controller ? (but.... if the gate deny access, I think it's a 403 error, not 404).

Snapey's avatar

you can get a 404 from your controller also. For example, eloquent findOrFail

Are you sure its not reaching your controller?

munazzil's avatar

Try with below one

php artisan cache:clear

Please or to participate in this conversation.