angular6:Request header 字段 Access-Control-Allow-Origin 不允许在预检响应中 Access-Control-Allow-Headers
angular6:Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response
使用后端 yii2 高级框架,使用 POST 方法调用 api 请求得到错误: Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers 在预检响应中。
const BASE_API_URL = 'http://localhost/harshini/kpa/backend/frontend/web/index.php?r=site%2Flogin';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'})
};
sendValue(message: Kpa) {
return this.http.put(BASE_API_URL, message, httpOptions);
}
正在添加图片,请帮忙。
看起来像 cors
问题,
从服务器端启用 cors
。
请参考这个 link
使用后端 yii2 高级框架,使用 POST 方法调用 api 请求得到错误: Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers 在预检响应中。
const BASE_API_URL = 'http://localhost/harshini/kpa/backend/frontend/web/index.php?r=site%2Flogin';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'})
};
sendValue(message: Kpa) {
return this.http.put(BASE_API_URL, message, httpOptions);
}
看起来像 cors
问题,
从服务器端启用 cors
。
请参考这个 link