fix(csr): send csrf token with component rpc
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user