angular6:请求标头字段在飞行前响应中Access-Control-Allow-Headers不允许Access-Control-Allow-Origin

时间:2019-06-03 12:07:23

标签: angular6 yii2-advanced-app

使用后端yii2高级框架,使用POST方法调用api请求,将错误显示为:在飞行前响应中,Access-Control-Allow-Headers不允许使用请求标头字段Access-Control-Allow-Origin。

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);
  }

enter image description here 在这里添加图片,请帮忙。

1 个答案:

答案 0 :(得分:1)

看起来像cors问题,

从服务器端启用cors。 请参考此链接Yii2 cors filters error that No 'Access-Control-Allow-Origin' header is present

相关问题