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

Sorry, I have a routes problem in laravel livewire. I want to test my login form validation on my website by sending empty input and continuously clicking the submit button (after giving a response of course), and on the fifth (5) click I have a problem “The GET method is not supported for this route. Supported methods: POST”. Does anyone know about this problem? Because I also tried it on a simple form on localhost and there was no error.

I use laravel livewire 2.2

This is the code on my website,

Blade

<form wire:submit.prevent="check">
   <div class="form-group">
      <label class="label">Email</label>
      <div class="input-group">
         <input wire:model.defer="email" type="email" class="form-control" placeholder="xxx@xxx.xx">
         <div class="input-group-append">
            <span class="input-group-text">
            <i class="mdi mdi-check-circle-outline"></i>
            </span>
         </div>
      </div>
      @error('email')<label class="text-danger">{{ $message }}</label> @enderror
   </div>
   <div class="form-group">
      <label class="label">Password</label>
      <div class="input-group">
         <input wire:model.defer="password" type="password" class="form-control" placeholder="**********">
         <div class="input-group-append">
            <span class="input-group-text">
            <i class="mdi mdi-check-circle-outline"></i>
            </span>
         </div>
      </div>
      @error('password')<label class="text-danger">{{ $message }}</label> @enderror
   </div>
   <div class="form-group">
      <button class="btn btn-success submit-btn btn-block" wire:loading.attr="disabled" >
         <div wire:loading.remove>Login</div>
         <div wire:loading>
            <div class="loading-bar bg-white"></div>
            <div class="loading-bar bg-white"></div>
            <div class="loading-bar bg-white"></div>
            <div class="loading-bar bg-white"></div>
         </div>
      </button>
   </div>
</form>

Controller

class Login extends Component
{
    
    public $password;
    public $email;

    protected $rules = [
            'password' => 'required',
            'email' => 'required|email',
        ];
        
    public function check()
    {
    
        $this->validate($this->rules);

        if (Auth::attempt(['email' => $this->email, 'password' => $this->password]))
        {
            
            redirect()->to('livewire/add');
            
        }else
        {   
            
            $this->dispatchBrowserEvent('alert', ['type' => 'error', 'title' => 'Error','message' => 'Credential not valid']);

        }
        
    }
    
    public function render()
    {
        return view('livewire.login')->extends('backend.v2.master');
    }
}

Routes

Route::group(['prefix' => 'livewire'], function() {
       Route::get('/login',Login::class);
       Route::get('/add',Add::class);
});

First submit result image

Error result after the fifth click

image

Thanks for your help.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 27 (1 by maintainers)

Most upvoted comments

@ideadx did you forget to use the WithPagination trait by chance?

I had the same problem … to solve it what I did was to put this:

use WithPagination;

protected $paginationTheme = ‘bootstrap’;

use this for your doubts https://laravel-livewire.com/docs/2.x/pagination

Having the same issue while navigating using $records->links() for pagination for the records.

Everything works perfectly fine on my local environment, but upon uploading the application to the server, I’m facing the following error:

The GET method is not supported for route livewire/message/actualizacionBD. Supported methods: POST.

I’ve double-checked my code, and I’m certain that I’m using the correct method in my application. It seems to be a server-specific problem as I’m not encountering this error locally. It only happends when I try to upload a excel file with (laravel Excel ext) https://laravel-excel.com/

👋 Oh Hi! I’m Squishy, the friendly jellyfish that manages Livewire issues.

I see this issue has been closed.

Here in the Livewire repo, we have an “issues can be closed guilt-free and without explanation” policy.

If for ANY reason you think this issue hasn’t been resolved, PLEASE feel empowered to re-open it.

Re-opening actually helps us track which issues are a priority.

Reply “REOPEN” to this comment and we’ll happily re-open it for you!

(More info on this philosophy here: https://twitter.com/calebporzio/status/1321864801295978497)