mozew's avatar
Level 6

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

Look at my codes

web.php

Route::post('/code', 'HomeController@code')->name('code');
Route::post('/send', 'HomeController@send')->name('send');

HomeController.php

public function code()
{
    return view('Home.send');
}

public function send ($mobile = '09389267856')
{
    try{
        $api = new \Kavenegar\KavenegarApi( 

"416576364B7A5552744A4852415477536254534C367755496E4F32344F426768" ); }

send,blade.php

 <form action="{{ route('send') }}" method="post">
        ........./*code gereI*/
 </form

I see this error.

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException The GET method is not supported for this route. Supported methods: POST.

0 likes
11 replies
devfrey's avatar
devfrey
Best Answer
Level 11

Change

Route::post('/code', 'HomeController@code')->name('code');

to

Route::get('/code', 'HomeController@code')->name('code');
6 likes
ye_thiha's avatar

i also face similar error "GET method is not supported for this route. Supported methods: POST." I create the new route for that method/function with a different name and it works.

1 like
metbhai's avatar

Hello I am facing the same issue. infact when i am running on different server it is running without any issue. Any idea where could be the problem? Is it a server issue?

  • Throw a method not allowed HTTP exception. *

    • @param array $others
    • @param string $method
    • @return void
    • @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException */ protected function methodNotAllowed(array $others, $method) { throw new MethodNotAllowedHttpException( $others, sprintf( 'The %s method is not supported for this route. Supported methods: %s.', $method, implode(', ', $others) ) ); }

    /**

    • Get routes from the collection by method.
    • @param string|null $method
    • @return array */ public function get($method = null) { return is_null($method) ? $this->getRoutes() : Arr::get($this->routes, $method, []); }

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

wahabdiyal's avatar

i m facing same issue on live server local server running fine but live server makes the issue.

i m facing problem in api.php

3 likes
ian_h's avatar

Have any headers been set at the server level?

I have this in one of my nginx configs for example:

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';

The 2nd line defines what the server will allow to go through before it gets to the code level... maybe something relevant to your situation too?

Cheers..

Ian

xenbros's avatar

for future, if you are using api.php make sure you are using the Accept : application/json when calling the API

kokoshneta's avatar

@xenbros Please don’t resurrect questions that are several years old just to post things that have nothing to do with the question.

matiullahbannu's avatar

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException The GET method is not supported for route home. Supported methods: POST. i have this error when we call a post method. so, i this error solution please.

Please or to participate in this conversation.