Skip to content

Commit

Permalink
[4.x] Fix static caching with Livewire 3 (#8762)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
aerni and jasonvarga authored Sep 25, 2023
1 parent 87070a3 commit 703f8fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/StaticCaching/Cachers/FileCacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,19 @@ public function getNocacheJs(): string
for (const meta of document.querySelectorAll('meta[content="$csrfPlaceholder"]')) {
meta.content = data.csrf;
}
for (const input of document.querySelectorAll('script[data-csrf="$csrfPlaceholder"]')) {
input.setAttribute('data-csrf', data.csrf);
}
if (window.hasOwnProperty('livewire_token')) {
window.livewire_token = data.csrf
}
if (window.hasOwnProperty('livewireScriptConfig')) {
window.livewireScriptConfig.csrf = data.csrf
}
document.dispatchEvent(new CustomEvent('statamic:nocache.replaced'));
});
})();
Expand Down

0 comments on commit 703f8fd

Please sign in to comment.