3
votes

I have a simple blade form mith post method and csrf token:

<form name="login" action="{{ route('login.do') }}" method="post" autocomplete="off">
    @csrf
    <label>
        <span class="field icon-envelope">E-mail:</span>
        <input type="email" name="email" required/>
    </label>

    <label>
        <span class="field icon-unlock-alt">Password:</span>
        <input type="password" name="password_check"/>
    </label>

    <button class="gradient gradient-orange radius icon-sign-in" type="submit">Send</button>
</form>

and the route in routes/web.php:

Route::post('login', 'AuthController@login')->name('login.do');

when I submit the form, I get the error:

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException

The GET method is not supported for this route. Supported methods: POST.

As you can see, the route and the form are ok, but something is messing it up and changing the method. It won't even get to the controller layer.

some infos:

-Laravel 8.12

-I have no customized middleware

-The htaccess and config/cors are default

-The route doesn't end with a slash nor is duplicated

-Whenever I do an alteration I clean the caches

-The APP_URL starts with http and SESSION_SECURE_COOKIE is set to false due to it

-The APP_ENV is production

What can it be? I've read it may be something in the server that's blocking the request and changing its method, so I'm not sure if the error is laravel or server related.

1
Is that error message for that page? Do you maybe redirect after logging in or something? - brombeer
did you try dd() your values for checking request reached your method or not. - abhay
Try once by rewrite you route like this Route::post('/update',[PersonController::class, 'update'])->name('update'); - abhay
The login isn't being done. as I said, it won't even get to the controller layer. - Fabio Silva
Please share more details - how do you submit the form? Is there any Javascript handler changing the form method? - Nico Haase

1 Answers

-1
votes
public function login(Request $request){
    
   dd($request->all());
    
}