fix: 修复服务端渲染请求缺少csrf token 问题

This commit is contained in:
feng626
2022-08-19 10:34:16 +08:00
committed by Jiangjie.Bai
parent bb4da12366
commit 24a1738e73
2 changed files with 1 additions and 5 deletions

View File

@@ -132,6 +132,7 @@ function setAjaxCSRFToken() {
$.ajaxSetup({
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-JMS-LOGIN-TYPE", "W");
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
@@ -270,13 +271,11 @@ function requestApi(props) {
if (typeof(dataBody) === "object") {
dataBody = JSON.stringify(dataBody)
}
var beforeSend = props.beforeSend || function (request) {}
$.ajax({
url: props.url,
type: props.method || "PATCH",
data: dataBody,
beforeSend: beforeSend,
contentType: props.content_type || "application/json; charset=utf-8",
dataType: props.data_type || "json"
}).done(function (data, textStatue, jqXHR) {