Angular 9 Intercom API,如何修复 CORS 错误?

Angular 9 Intercom API, how to fix CORS error?

我正在尝试访问对讲机 API 并使用他们的 API 在那里创建公司 https://developers.intercom.com/intercom-api-reference/reference#create-or-update-company 但出现 CORS 错误!

URL = 'https://api.intercom.io/companies'

this.httpOptions = {
    headers: new HttpHeaders({
      'Content-Type':  'application/json',
      'Authorization': 'Bearer ....',
      'Access-Control-Allow-Origin': '*'
    })
 };

const path = this.URL + '/companies';
return this.http.post(path, data, {headers: this.httpOptions});

如何修复 CORS 错误?

Intercome apis 在客户端不起作用。 您需要使用服务器端包在对讲机上进行 api 呼叫。

您可以使用其中之一:

1- Nodejs http 客户端包:axios

2-官方节点包:intercom-node