Skip to content

Comments

[5.x] Fix CSRF token on pages excluded from static caching#14056

Merged
jasonvarga merged 2 commits into5.xfrom
static-cache-exclusions
Feb 25, 2026
Merged

[5.x] Fix CSRF token on pages excluded from static caching#14056
jasonvarga merged 2 commits into5.xfrom
static-cache-exclusions

Conversation

@duncanmcclean
Copy link
Member

This pull request fixes an issue where excluded pages received STATAMIC_CSRF_TOKEN instead of the real token, causing 419 errors when submitting forms.

The URL exclusion check was happening in cachePage() after the replacers had already modified the response (eg. the real token being replaced w/ the placeholder). This PR moves the check into shouldBeCached() so excluded pages skip the replacement logic entirely.

Fixes #14053

return false;
}

if ($this->cacher instanceof AbstractCacher && $this->cacher->isExcluded($this->cacher->getUrl($request))) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm checking the AbstractCacher here because the isExcluded method doesn't exist on the Cacher interface.

@jasonvarga jasonvarga merged commit f8094c4 into 5.x Feb 25, 2026
28 checks passed
@jasonvarga jasonvarga deleted the static-cache-exclusions branch February 25, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[5.x] Getting 419 expired on livewire update call after updating statamic/cms to v5.73.8

2 participants