【发布时间】:2019-06-05 19:02:16
【问题描述】:
使用后端yii2高级框架,使用POST方法调用api请求报错为:请求头字段Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response。
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);
}
【问题讨论】:
-
请任何人帮我解决这个问题,我在过去四天里一直在这个问题上。
标签: angular6 yii2-advanced-app