left4me/l4d2web/static/js/csrf.js
2026-05-05 23:47:06 +02:00

10 lines
326 B
JavaScript

document.addEventListener("DOMContentLoaded", () => {
const token = document.querySelector("meta[name='csrf-token']")?.getAttribute("content");
if (!token || !window.htmx || !window.htmx.on) {
return;
}
window.htmx.on("htmx:configRequest", (event) => {
event.detail.headers["X-CSRF-Token"] = token;
});
});