The POST method is not supported for this route. Supported methods: GET, HEAD. Laravel
Solution 1:
There are multiple ways you can handle this:
If you insist on using
PUT
you can change the form action toPOST
and add a hiddenmethod_field
that has a valuePUT
and a hidden csrf field (if you are using blade then you just need to add@csrf_field
and{{ method_field('PUT') }}
). This way the form would accept the request.You can simply change the route and form method to
POST
. It will work just fine since you are the one defining the route and not using the resource group.
Solution 2:
I know this is not the solution to OPs post. However, this post is the first one indexed by Google when I searched for answers to this error. For this reason I feel this will benefit others.
The following error...
The POST method is not supported for this route. Supported methods: GET, HEAD.
was caused by not clearing the routing cache
php artisan route:cache
Solution 3:
add @method('PUT') on the form
exp:
<form action="..." method="POST">
@csrf
@method('PUT')
</form>