Support CSRF in HTMX non-form posts.
This commit is contained in:
parent
b2f64b62f4
commit
8860b981e6
3 changed files with 14 additions and 0 deletions
|
|
@ -19,4 +19,14 @@
|
|||
{{define "js"}}
|
||||
<script src="https://unpkg.com/htmx.org@1.6.1"></script>
|
||||
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||
{{end}}
|
||||
|
||||
{{define "footer"}}
|
||||
{{- if .CSRF}}
|
||||
<script>
|
||||
document.body.addEventListener('htmx:configRequest', (event) => {
|
||||
event.detail.parameters['csrf'] = '{{ .CSRF }}';
|
||||
})
|
||||
</script>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
|
@ -23,5 +23,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{template "footer"}}
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -38,5 +38,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{template "footer"}}
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue