You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if we could use named routes or config values inside the $except property of App\Http\Middleware\VerifyCsrfToken; however, having expressions as values inside the said property is frowned upon by PHP:
From IDE:
From browser (Flare?):
My suggestion is to add a mechanism that will allow the addition of CSRF-exempted URIs expressions, such as:
<?php// app/Http/Middleware/VerifyCsrfToken.phpnamespaceApp\Http\Middleware;
useIlluminate\Foundation\Http\Middleware\VerifyCsrfTokenasMiddleware;
class VerifyCsrfToken extends Middleware
{
/** * The URIs that should be excluded from CSRF verification. * * @var array<int, string> */protected$except = [
'/bluepay',
];
/** * Overrides \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::addExceptUrls() * All resolved URIs from this method will be merged with the values of the `$except` property */protectedfunctionaddExceptUrls(): array
{
// can even do some logic herereturn [
route('stripe.webhook'),
// other expressions
];
}
}
Please have a look at my PR that will enable this: #48196
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice if we could use named routes or config values inside the
$except
property ofApp\Http\Middleware\VerifyCsrfToken
; however, having expressions as values inside the said property is frowned upon by PHP:From IDE:

From browser (Flare?):

My suggestion is to add a mechanism that will allow the addition of CSRF-exempted URIs expressions, such as:
Please have a look at my PR that will enable this: #48196
Happy to know everyone's thoughts about this!
🦞
Beta Was this translation helpful? Give feedback.
All reactions