The POST method is not supported for route (route url). Supported methods: GET, HEAD.

Posted by

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Error Message:

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

This means you’re sending a POST request to a route that was only defined to accept GET or HEAD methods.


โœ… Root Cause

Laravel route declaration controls which HTTP methods a route can accept. If you send a POST request to a route defined with only GET, Laravel will throw this error.


โœ… Step-by-Step Solution

๐Ÿฅ‡ Step 1: Locate Your Form or AJAX Call

Check where you’re submitting the request (HTML form, JavaScript/AJAX, etc.).

<form action="{{ url('/my-route') }}" method="POST">
    @csrf
    <input type="text" name="title">
    <button type="submit">Submit</button>
</form>

OR

fetch('/my-route', {
    method: 'POST',
    body: JSON.stringify({ title: 'My title' }),
    headers: {
        'Content-Type': 'application/json',
        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
    }
});

๐Ÿฅˆ Step 2: Check Your routes/web.php File

Ensure your route supports POST:

โŒ Wrong (Only GET)

Route::get('/my-route', 'MyController@store');

โœ… Correct (Supports POST)

Route::post('/my-route', 'MyController@store');

โœ… Or Support Both GET and POST

Route::match(['get', 'post'], '/my-route', 'MyController@store');

โœ… Or Accept All HTTP Verbs (use carefully)

Route::any('/my-route', 'MyController@store');

๐Ÿฅ‰ Step 3: Check Your Controller Method (Optional)

Make sure your controller method exists:

public function store(Request $request)
{
    // Handle the POST data
}

๐Ÿงช Step 4: Test the Route

Use php artisan route:list to verify the route methods:

php artisan route:list

Check if /my-route accepts POST. If not, your route is wrongly defined.


๐Ÿ› ๏ธ Bonus Tip: Use Route Names for Cleaner HTML Forms

Route::post('/submit-form', 'FormController@submit')->name('form.submit');
<form action="{{ route('form.submit') }}" method="POST">
    @csrf
    <input type="text" name="title">
    <button type="submit">Submit</button>
</form>

๐Ÿšจ Common Mistakes

MistakeFix
Form method is POST, but route only allows GETDefine route using Route::post(...)
Missing @csrf in Blade formAdd @csrf inside <form>
Using wrong URL in form actionUse {{ route('your.route.name') }} or url('/your-path')
Wrong controller method signatureEnsure method name and parameter match route definition

๐ŸŽฏ Final Working Example

routes/web.php

use App\Http\Controllers\MyFormController;

Route::get('/form', [MyFormController::class, 'index']);
Route::post('/form', [MyFormController::class, 'submit'])->name('form.submit');

MyFormController.php

public function index() {
    return view('form');
}

public function submit(Request $request) {
    // Validate and process
    return redirect('/form')->with('success', 'Form submitted!');
}

resources/views/form.blade.php

<form method="POST" action="{{ route('form.submit') }}">
    @csrf
    <input type="text" name="title" required>
    <button type="submit">Submit</button>
</form>

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x