fix(csr): send csrf token with component rpc
Quality / quality (ubuntu-latest) (push) Failing after 10m42s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 18:15:15 +05:30
parent 1719059fa0
commit 9637a47ec7
2 changed files with 30 additions and 2 deletions
+3 -2
View File
@@ -4138,13 +4138,14 @@ export const REACTIVE_RUNTIME = String.raw`
}
function callServerFunction(component, functionName, args) {
var csrf = document.querySelector('meta[name="wrnexus-csrf"]');
var csrfMatch = /(?:^|;\s*)wire-csrf=([^;]+)/.exec(document.cookie || "");
var csrf = csrfMatch ? decodeURIComponent(csrfMatch[1]) : "";
return fetch("/__wrnexus/rpc", {
method: "POST",
credentials: "same-origin",
headers: {
"content-type": "application/json",
"x-csrf-token": csrf ? csrf.getAttribute("content") || "" : "",
"x-csrf-token": csrf,
},
body: JSON.stringify({ component: component, function: functionName, args: args || [] }),
}).then(function (response) {