Skip to content

Commit

Permalink
Use CSRF token replaced by Statamic
Browse files Browse the repository at this point in the history
  • Loading branch information
robdekort committed Dec 9, 2023
1 parent f3e0cd1 commit 6f4255c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion resources/views/snippets/_form_handler.antlers.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<script src="/vendor/statamic/frontend/js/helpers.js"></script>
<script>
window.livewire_token = ''
document.addEventListener('alpine:initializing', () => {
Alpine.data('formHandler', () => ({
success: false,
Expand All @@ -18,7 +19,16 @@
this.form = this.$form(
'post',
this.$refs.form.getAttribute('action'),
JSON.parse(this.$refs.form.getAttribute('x-data')).form
JSON.parse(this.$refs.form.getAttribute('x-data')).form,
{
headers: {
'X-CSRF-Token': {
toString() {
return window.livewire_token;
}
},
}
},
)
},
succesHook() {
Expand Down

0 comments on commit 6f4255c

Please sign in to comment.