FREDERIC LD's avatar

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

Hello,

I keep getting this error on my remote staging server when interacting with my component. The GET method is not supported for this route. Supported methods: POST.

Request URL: https://www.mywebsite.co.uk/livewire/message/admin.add-edit-client-users Request Method: POST Status Code: 405

I can interact with the component a little and after a few clicks it fails.

The strange things is I can interact with the component on my local machine and I get not errors at all. Although my request is with POST, the error indicates there is an issue with a GET request I have commented out pretty much all my code to see if it would change anything but it does not

the php

namespace App\Http\Livewire\Admin;

use Livewire\Component;

public $activeTab;

public function mount()
{
     $this->activeTab = "user-details";
}

public function updateTab($tabName)
    {
        $this->activeTab = $tabName;
    }

    public function render()
    {
        return view('livewire.admin.add-edit-client-users');
    }
}

blade

<div>

    <form wire:submit.prevent="submit">

        <ul class="nav nav-tabs mydir-tabs" role="tablist">

            <li class="nav-item">
              <a class="nav-link @if ($activeTab == "user-details") active @endif" data-toggle="tab" href="#user-details" wire:click="updateTab('user-details')">User details</a>
            </li>
            <li class="nav-item">
              <a class="nav-link @if ($activeTab == "additional-information") active @endif" data-toggle="tab" href="#additional-information" wire:click="updateTab('additional-information')">Additional information</a>
            </li>
            <li class="nav-item">
              <a class="nav-link @if ($activeTab == "institution") active @endif data-toggle="tab" href="#institution" wire:click="updateTab('institution')">Institution</a>
            </li>

        </ul>


        <!-- Tab panes -->
        <div class="tab-content">
                ...
        </div>

    </form>

</div>

clicking on the tabs wire:click triggers a functions that updates 1 variable. it works for 4, 5 clicks but fails after that.... It is quite frustrating because I don't understand the issue. Why does it work for the first few clicks and then fails?

Is it my code that is wrong is there something else not quite working with livewire.

Here is the strack trace

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST. in file /home/web/site/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php on line 117

#0 /home/web/site/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php(103): Illuminate\Routing\AbstractRouteCollection->methodNotAllowed(Array, 'GET') #1 /home/web/site/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php(40): Illuminate\Routing\AbstractRouteCollection->getRouteForMethods(Object(Illuminate\Http\Request), Array) #2 /home/web/site/vendor/laravel/framework/src/Illuminate/Routing/CompiledRouteCollection.php(144): Illuminate\Routing\AbstractRouteCollection->handleMatchedRoute(Object(Illuminate\Http\Request), NULL) #3 /home/web/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(647): Illuminate\Routing\CompiledRouteCollection->match(Object(Illuminate\Http\Request)) #4 /home/web/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request)) #5 /home/web/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #6 /home/web/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #7 /home/web/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request)) #8 /home/web/site/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #9 /home/web/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure)) #10 /home/web/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #11 /home/web/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure)) #12 /home/web/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #13 /home/web/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure)) #14 /home/web/site/vendor/fruitcake/laravel-cors/src/HandleCors.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #15 /home/web/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure)) #16 /home/web/site/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #17 /home/web/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure)) #18 /home/web/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #19 /home/web/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #20 /home/web/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #21 /home/web/site/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #22 {main}

0 likes
6 replies
abrada's avatar

Show the output of this command

php artisan route:list
FREDERIC LD's avatar

@traster100

I have many many routes but the one we are interested in is

Route::prefix('/admin/')->middleware('web','auth:admin','admin')->name('admin.')->namespace('Admin')->domain('www.'.$domain)->group(function(){

   Route::resource('users', 'UserController', ['except' => ['show']]);

});

and the auto created livewire routes

                                     | GET|HEAD  | livewire/livewire.js                                    | generated::ggwF1Yy225ckxCTo                      | Livewire\Controllers\LivewireJavaScriptAssets@source                            |                                                        |
|                                     | GET|HEAD  | livewire/livewire.js.map                                | generated::zWZOuh8ss1bkloXT                      | Livewire\Controllers\LivewireJavaScriptAssets@maps                              |                                                        |
|                                     | POST      | livewire/message/{name}                                 | livewire.message                                 | Livewire\Controllers\HttpConnectionHandler                                      | web                                                    |
|                                     | GET|HEAD  | livewire/preview-file/{filename}                        | livewire.preview-file                            | Livewire\Controllers\FilePreviewHandler@handle                                  | web                                                    |
|                                     | POST      | livewire/upload-file                                    | livewire.upload-file                             | Livewire\Controllers\FileUploadHandler@handle                                   | web                                                    |

I reduced the template to

<div>

<a class="nav-link active" data-toggle="tab" href="#additional-information" wire:click="updateTab('additional-information')">Additional information</a>
</div>

and I still get the issue...

FREDERIC LD's avatar
FREDERIC LD
OP
Best Answer
Level 4

The issue has been solved! The Apache Module: Evasive was the issue

1 like
xmazlan's avatar

Import Livewire WithPagination

use Livewire\WithPagination;

place this line to your Livewire Class:

use WithPagination;

Looks like this

<?php

namespace App\Livewire;

// others
use Livewire\WithPagination; // this

class YourClassName extends Component
{
    use WithPagination; // and this

    // Your function here
}
3 likes
Rafhael1's avatar

I hope my answer can be helpful to someone. In my case, I was encountering this error because of poor Nginx configuration. Check yours.

Please or to participate in this conversation.