Reputation: 3
After I set up a webhook from my github to my laravel website, one of the pages stopped working. (Control Panel)
If I delete the webhook from Github, the page starts working again.
The symptoms are either Error 419 Page Expired or the page doesn't load at all after trying to login.
Any clues? I am thinking it might be related to VerifyCsrfToken exceptions but I don't know how I would add github webhook in there.
Upvotes: 0
Views: 1274
Reputation: 638
Thank you Vinny for showing the photo of the Github webhooks setup. To resolve your problem you will need to do the following three steps:
APPLICATION/JSON
in the Content-Type
option
of Github Webhooks. As Laravel doesn't include VerifyCSRFToken
middleware for the JSON.api
middleware group. To do that you need to define this endpoint in the api.php
NOT in web.php
./api
with your domain name and the path defined in your api.php
For more context, you can visit this documentation URL. https://laravel.com/docs/8.x/middleware#middleware-groups
Note: I would recommend using signature verification to avoid bad usage of your endpoint and webhook triggers. To do that you can follow this nice article.
https://dev.to/ryan1/how-to-validate-github-webhooks-with-laravel-and-php-2he1
Upvotes: 2