close

[Solved] The POST method is not supported for this route. Supported methods: GET, HEAD

I have one POST Route But When I am using POST request for this Rout I am facing the following error: The POST method is not supported for this route. Supported methods: GET, HEAD in Laravel. In this Exerror article, We are going to learn about How to reproduce this error and we will discuss All Possible Solutions Lets Get Start with This Article.

How The POST method is not supported for this route. Supported methods: GET, HEAD Error Occurs?

I have one POST Route But When I am using POST request for this Rout I am facing the following error:

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

So here I am writing all the possible solutions that I have tried to resolve this error.

How To Solve The POST method is not supported for this route. Supported methods: GET, HEAD Error?

  1. How To Solve The POST method is not supported for this route. Supported methods: GET, HEAD Error?

    To Solve The POST method is not supported for this route. Supported methods: GET, HEAD Error If You are trying to submit an HTML form with a POST request then you need to add two fields in your form. The first one is @csrf_field and the Second one is @method('PUT') or You can add {{ method_field('PUT') }} And now, Your error will be solved.

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

    To Solve The POST method is not supported for this route. Supported methods: GET, HEAD Error You Just need to clear your route cache and it will resolve your issue. This error usually occurs because of not clearing the route cache. So You just need to run the artisan command with route:cache from the root of your project. Just run this command: php artisan route:cache And now, Your error will be solved Successfully. Thank You.

Solution 1: Clear route cache

To Solve The POST method is not supported for this route. Supported methods: GET, HEAD Error You Just need to clear your route cache and it will resolve your issue. This error usually occurs because of not clearing the route cache. So You just need to run the artisan command with route:cache from the root of your project. Just run this command.

php artisan route:cache

And now, Your error will be solved Successfully. Thank You.

Solution 2: add Method in your Form

If You are trying to submit an HTML form with a POST request then you need to add two fields in your form. The first one is @csrf_field and the Second one is @method(‘PUT’) or You can add {{ method_field(‘PUT’) }} Just like this.

<form action="..." method="POST">

@csrf  

@method('PUT') 
//OR {{ method_field('PUT') }} 
//OR  <input type="hidden" name="_method" value="PUT">


</form>

And now, Your error will be solved.

Conclusion

It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment