diff --git a/src/StaticCaching/Cachers/FileCacher.php b/src/StaticCaching/Cachers/FileCacher.php index 7f06c761f7..603fca634d 100644 --- a/src/StaticCaching/Cachers/FileCacher.php +++ b/src/StaticCaching/Cachers/FileCacher.php @@ -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')); }); })();