当我尝试发送http请求时,我收到了有关CORS的错误。
XMLHttpRequest cannot load 'sever-domain'.
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'my-firebsase-hosted-app-domain' is therefore not allowed access.
然后我将标题设置为我的http请求。
let headers = new Headers(
{
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/x-www-form-urlencoded'
}
);
let options = new RequestOptions({ headers: headers });
this.postRequestSub = this._http.post(this.url, body, options);
但我仍然有同样的错误,这不是解决问题的正确方法吗?