Webhooks routes references incorrect VerifyCsrfToken middleware
Description
I tried adding webhooks for product updates, however every webhook fired from Shopify results in a http 419. Looking at the actions.php where the webhook routes are defined, I see the VerifyCsrfToken class is imported using the old FQCN: use App\Http\Middleware\VerifyCsrfToken.
This should be: \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class
Using laravel 11.x
Steps to reproduce
- Open actions.php
- See that the wrong import statement is used on line 3.
Environment
Environment Application Name: JBC Laravel Version: 11.44.2 PHP Version: 8.4.7 Composer Version: 2.8.8 Environment: local Debug Mode: ENABLED URL: jbc-web.test Maintenance Mode: OFF Timezone: UTC Locale: en
Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED
Drivers Broadcasting: log Cache: file Database: sqlite Logs: stack / single Mail: postmark Queue: sync Session: file
Statamic Addons: 2 Sites: 2 (English, Dutch) Stache Watcher: Enabled (auto) Static Caching: Disabled Version: 5.55.0 PRO
Statamic Addons statamic-rad-pack/shopify: 5.3.0 statamic/seo-pro: 6.6.5
update: extending the \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class when creating the App\Http\Middleware\VerifyCsrfToken class in the hopes it would resolve the 419 issue, didn't help.
Running this:
app('router')->getRoutes()->getByName('statamic.shopify.webhook.product.update')->gatherMiddleware()
Returns this:
array:2 [ 0 => "web" 1 => "StatamicRadPack\Shopify\Http\Middleware\VerifyShopifyHeaders" ]
Which basically means the web middleware group is still applied (which contains the VerifyCsrfToken middleware):
I've opened a PR here - https://github.com/statamic-rad-pack/shopify/pull/289 - let me know if this solves your issue
Hi Ryan, yes that works! Thanks for the quick follow-up. :)
I've just tagged v5.3.1 which includes this.