Error When POSTing A Form To Auth Route (MethodNotAllowedHttpException)

- 1 answer

I am trying to POST a form BEFORE user authentication. User inputs data into a form and POST it to the route protected by auth:

Route::group(['middleware'=>'auth'], function(){ Route::post('v2/payment/start/','[email protected]');


If a user IS authenticated BEFORE the POST, the request is processed OK. If a user is NOT authenticated, user gets the login form, enters login password and receives the error "MethodNotAllowedHttpException".

What could be the cause of this? In my LoginController I have:

return redirect()->intended($this->redirectPath());

so, the user should be redirected OK.

Where could be the error?



The problem is that after user is authenticated, they will be redirected using GET method (redirections always use GET method). So you can try to use:

Route::match(['get', 'post'], 'v2/payment/start/','[email protected]');

instead of

Route::post('v2/payment/start/','[email protected]');

to make this route working with both GET and POST methods.