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

dogma's avatar
Level 1

POST Request Error on GET page load

On my production server I receive this error in the command line after loading my login page:

POST https://example.com/login 404

I have following routes:

Route::get('/login', [AuthController::class, 'create'])
    ->name('login');

Route::post('/login', [AuthController::class, 'store']);

The create function is:

public function create()
    {
        return view('auth.login');
    }

My page content:

<form method="POST" action="https://example.com/login" id="login-form">

        <input type="hidden" name="_token" value="IchangedThismanuallyforTheforum">        <!-- Session Status -->
                        <!-- Email Address -->
                        <div>
                <input id="Email" class="block mt-1 w-full input-field" type="Email" name="Email" required="required" placeholder="E-Mail" autofocus="autofocus" autocomplete="Email">
                <span class="invalid-feedback text-red-500 text-sm font-bold" id="email_error" role="alert"></span>
            </div>

            <!-- Password -->
            <div class="mt-4 relative">
                <input class="w-full border-gray-200 pl-4 py-3 rounded password" id="password" type="password" placeholder="Passwort*" required="" name="password">
                            </div>
            <div class="mt-4">
                <div class="basic_checkbox mt-3 ml-1 font-light  ">
    <input type="checkbox" id="remember" class="" name="remember">

    <label class="rounded-sm " for="remember">
    </label>

    <div class="basic_checkbox_text ml-4 text-sm greyColor">
Remember me
    </div>
</div>
            </div>
            <div class="mt-5">
                <button type="submit" class="px-4 py-2 bg-black rounded-md text-white focus:outline-none w-full transition blue-button">
    Login
</button>
            </div>
        </form>

Further I realised that the route looks kind of weird on my production server:

php artisan route:list

delivers:

|  | GET|HEAD | login | login | App\Http\Controllers\Web\Auth\AuthController@create | web 
|  | POST | login | generated::viupFffXjQrlBCAQ | App\Http\Controllers\Web\Auth\AuthController@store  | web                                             |

I host via Laravel Forge, everything else works just fine. The app runs in Maintenance mode and the page is password secured via "HTTP basic access authentication", which worked as well. Since I can access the page..

The page renders as expected, I just can't login..

The same code works on my localhost dev Server without triggering the POST Request (or whatever it is) and also with the login functionality

Any ideas?

0 likes
12 replies
tisuchi's avatar

@dogma Two concerns.

  1. Make sure you have nothing with case-sensitive issues. Since it's working locally!
  2. Maybe this is the reason <input type="hidden" name="_token" value="IchangedThismanuallyforTheforum"> . Instead of using hidden input field, you may use @csrf directly.
dogma's avatar
Level 1

@tisuchi

  1. What could be case sensitive in this context?
  2. I just copied the html browser code. I use @csrf in the template :)
tisuchi's avatar

@dogma For example: This might work in the local machine but not work in the server.

Authcontroller
Snapey's avatar

but your login form displays ok?

And the login form has the url domain.com/login ?

dogma's avatar
Level 1

@Snapey Yes! It displays without any error.. it just doesn't work :D and before anything is tried, there is the given error in the console..

dogma's avatar
Level 1

Checked it :/ The strangest Thing is, that I got an

GET https://example.com/login 404 

today and the page is loading correctly?

Dragon_Worrior's avatar

@dogma actually same error occur with my code but when i using this {{ csrf_field() }} my form work. so try this.

1 like

Please or to participate in this conversation.