【发布时间】:2020-01-30 07:04:58
【问题描述】:
我托盘访问端点并获取令牌,但我有一个错误: 从源“http:localhost:51780”访问“https://ptyi.test.com:8443/users/authenticate”处的 XMLHttpRequest 已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:没有“访问控制-允许-来源”;请求的资源上存在标头。我该如何解决?为什么要通过邮递员访问?提前谢谢!!
$.ajax({
type:"POST",
url: "https://ptyi.test.com:8443/users/authenticate",
data: { username :"test@sur.com" , password : "ff12dfb3L$"},
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
alert(result)
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status + " \n" + xhr.responseText, "\n" + thrownError);
},
});
});
【问题讨论】: