livewire / livewire

A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
MIT License
22.21k stars 1.55k forks source link

wire:click returns a 405 error #2477

Closed joval-sv closed 3 years ago

joval-sv commented 3 years ago

Description

SPA that is handled by a class, is defined in routes as Route::get('/path/{id}',MyClass::class), and any wire:click methods return a http/405 error "Method not allowed"

Exact steps to reproduce

Press any button with wire:click="method"

Stripped-down, copy-pastable code snippets

The shown page in my case is: http://olt.sv.ibw/olt/4

And when a button is clicked, The browser logs a post request to: http://olt.sv.ibw/livewire/message/olt.show

HTTP/1.1 405 Method Not Allowed Server: nginx/1.12.2 Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive allow: POST Cache-Control: no-cache, private date: Tue, 09 Feb 2021 04:11:43 GMT Set-Cookie: XSRF-TOKEN=...%3D; expires=Tue, 09-Feb-2021 06:11:43 GMT; Max-Age=7200; path=/; samesite=lax Set-Cookie: olt_manager_session=...%3D; expires=Tue, 09-Feb-2021 06:11:43 GMT; Max-Age=7200; path=/; httponly; samesite=lax

Here is the html:

 <button wire:click="toggle_slot0" class="btn btn-purple">IP Pools</button>

I have another development site with livewire 2.3.15 and it works as expected, but reverting the package back to this version also does not work.

Context

joval-sv commented 3 years ago

This is te output from composer update

$ composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 22 updates, 0 removals
  - Upgrading enlightn/enlightn (v1.8.0 => v1.11.0)
  - Upgrading facade/ignition (2.5.10 => 2.5.11)
  - Upgrading livewire/livewire (v2.3.10 => v2.3.16)
  - Upgrading phpstan/phpstan (0.12.71 => 0.12.74)
  - Upgrading symfony/cache (v5.2.2 => v5.2.3)
  - Upgrading symfony/config (v5.2.2 => v5.2.3)
  - Upgrading symfony/console (v5.2.2 => v5.2.3)
  - Upgrading symfony/css-selector (v5.2.2 => v5.2.3)
  - Upgrading symfony/error-handler (v5.2.2 => v5.2.3)
  - Upgrading symfony/event-dispatcher (v5.2.2 => v5.2.3)
  - Upgrading symfony/filesystem (v5.2.2 => v5.2.3)
  - Upgrading symfony/finder (v5.2.2 => v5.2.3)
  - Upgrading symfony/http-foundation (v5.2.2 => v5.2.3)
  - Upgrading symfony/http-kernel (v5.2.2 => v5.2.3)
  - Upgrading symfony/mime (v5.2.2 => v5.2.3)
  - Upgrading symfony/process (v5.2.2 => v5.2.3)
  - Upgrading symfony/routing (v5.2.2 => v5.2.3)
  - Upgrading symfony/string (v5.2.2 => v5.2.3)
  - Upgrading symfony/translation (v5.2.2 => v5.2.3)
  - Upgrading symfony/var-dumper (v5.2.2 => v5.2.3)
  - Upgrading symfony/var-exporter (v5.2.2 => v5.2.3)
  - Upgrading symfony/yaml (v5.2.2 => v5.2.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 22 updates, 0 removals
  - Downloading symfony/finder (v5.2.3)
  - Downloading phpstan/phpstan (0.12.74)
  - Downloading symfony/mime (v5.2.3)
  - Downloading symfony/http-foundation (v5.2.3)
  - Downloading symfony/error-handler (v5.2.3)
  - Downloading symfony/http-kernel (v5.2.3)
  - Downloading symfony/console (v5.2.3)
  - Downloading symfony/yaml (v5.2.3)
  - Downloading enlightn/enlightn (v1.11.0)
  - Downloading facade/ignition (2.5.11)
  - Downloading livewire/livewire (v2.3.16)
  - Upgrading symfony/finder (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading phpstan/phpstan (0.12.71 => 0.12.74): Extracting archive
  - Upgrading symfony/process (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/css-selector (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/var-dumper (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/routing (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/mime (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/http-foundation (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/event-dispatcher (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/error-handler (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/http-kernel (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/string (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/console (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/translation (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/filesystem (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/yaml (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading enlightn/enlightn (v1.8.0 => v1.11.0): Extracting archive
  - Upgrading facade/ignition (2.5.10 => 2.5.11): Extracting archive
  - Upgrading livewire/livewire (v2.3.10 => v2.3.16): Extracting archive
  - Upgrading symfony/var-exporter (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/cache (v5.2.2 => v5.2.3): Extracting archive
  - Upgrading symfony/config (v5.2.2 => v5.2.3): Extracting archive
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: enlightn/enlightn
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: jenssegers/agent
Discovered Package: kyslik/column-sortable
Discovered Package: laravel/fortify
Discovered Package: laravel/jetstream
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: livewire/livewire
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
> @php artisan livewire:discover --ansi
Livewire auto-discovery manifest rebuilt!
> @php artisan vendor:publish --force --tag=livewire:assets --ansi
Copied Directory [/vendor/livewire/livewire/dist] To [/public/vendor/livewire]
Publishing complete.
95 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
calebporzio commented 3 years ago

Hi @joval-sv, I tried this set up in a new app and everything worked as expected.

Also, it looks like there was only 1 line of code that was changed between v2.3.15 and v2.3.16. You can see here: https://github.com/livewire/livewire/compare/v2.3.15...v2.3.16

I'm going to close this, but feel free to re-open if you have new information to present.

I recommend, trying to recreate the issue in a brand new laravel app, if it doesn't happen, start using process of elimination in your current app to identify the issue.

Thanks

squishythejellyfish commented 3 years ago

👋 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)

joval-sv commented 3 years ago

Hi Caleb,

I saw you posted a new version v2.3.17, where you addressed the issue from another user and this fixed my 405 errors. Just wanted to let you know.

On 2/9/2021 8:19 AM, Caleb Porzio wrote:

Hi @joval-sv https://github.com/joval-sv, I tried this set up in a new app and everything worked as expected.

Also, it looks like there was only 1 line of code that was changed between v2.3.15 and v2.3.16. You can see here: v2.3.15...v2.3.16 https://github.com/livewire/livewire/compare/v2.3.15...v2.3.16

I'm going to close this, but feel free to re-open if you have new information to present.

I recommend, trying to recreate the issue in a brand new laravel app, if it doesn't happen, start using process of elimination in your current app to identify the issue.

Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/livewire/livewire/issues/2477#issuecomment-775973454, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADY3IVJQCPIQARVUK77M52TS6E77LANCNFSM4XKICLOA.

Dimonka2 commented 3 years ago

I just got the same issue in a sub-component in a latest Livewire. Request is clearly "POST" on wire:click, but the error somewhere in roting says: \MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST.

I see in request's JSON "fingerprint" section that method is "GET", but it should not influence anything, right?

But what is really weird that the browser URL got changed to http://127.0.0.1:8001/livewire/message/{parent-component-name}

Update: Maybe it will help someone. This issue happens due to change of browser URL. This happens only if child component has a query string modification and parent component has no. Solution was to add query string update to the parent.

emergingdzns commented 11 months ago

@Dimonka2 I've suddenly got this error coming up. We didn't change our URLs or anything. Just suddenly started throwing these errors. I don't understand the update message you posted. I could really use some help figuring this out.