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?
Solved it.. I deleted all the HTTP Basic Authentication rules in Laravel forge... But thats not how it should work is it??
Had to follow this: https://repat.de/2022/07/404-with-content-using-basic-auth-with-nginx/
Please or to participate in this conversation.