对预检请求的响应没有't pass access control check. No '访问 - 控制 - 允许 - 原点' header is present on the requested resource. Origin ' http://localhost:3000 ' is therefore not allowed access. The response had HTTP status code 522. If an opaque response serves your needs, set the request'模式到'no-cors'以获取禁用CORS的资源 . 将'http://localhost:3000 ' is therefore not allowed access. The response had HTTP status code 522. If an opaque response serves your needs, set the request'模式发送到'no-cors'以获取禁用CORS的资源 .
如何向json添加请求标头?
var options = {
body: info,
type: 'json'
}
然后`
doGetCall(url, options = {}) {
let callOptions = {
method: 'GET'
}
callOptions.headers = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'http://localhost:3000'
}
return this.doCall(url, callOptions);
}
最后
doCall(url, options) {
if (!options.noauth) {
options.headers = options.headers || {};
options.headers.Authorization = 'Bearer ' + Account.token;
}
return fetch(url, options).then(response => response.json());
}
这没有用 . 请求标头包含:
访问控制请求报头:存取控制允许来源,授权,内容类型
但没有Access-Control-Allowed-Origin标头 . 如何添加 Headers ?