angular - 从 Angular 应用程序调用第三方 API 时无法传递客户标头选项
问题描述
我正在尝试向 dunzo API 发出 API 请求以生成访问令牌,并且它正在使用邮递员并获得响应,但是当我通过我的 Angular 应用程序请求时,它给了我一些以下错误
Access to XMLHttpRequest at 'https://api.dunzo.in/api/v1/token' from origin 'http://localhost:4700' has been blocked by CORS policy: Request header field client-secret is not allowed by Access-Control-Allow-Headers in preflight response.
我的代码在下面
getAuthHeaderOptionGenerateToken() {
let headers = new HttpHeaders();
headers = headers
.set('client-secret', 'xxx')
.set('client-id', 'xx')
.set('Content-Type', 'application/json')
.set('Accept', 'application/json')
.set('Accept-Language', 'en_US');
let option = {
headers: headers
};
return option
}
getAuthToken() {
return this.http.get < any > (this.api_Url + 'api/v1/token', this.getAuthHeaderOptionGenerateToken());
}
感谢您的任何回复。
解决方案
推荐阅读
- reactjs - 在现有的谷歌云静态存储桶中反应“下一个开始”
- tokenize - LaBSE 预处理器输出的文本表示?
- python - py2app 访问非python文件
- react-native - 一些地址在英国没有返回邮政编码
- python - 排序的数据框在连接两个数据框时以无序的方式返回数据
- nuget - 有没有办法检查 nuget 包是否已经在 ProGet Repo 上?
- javascript - 三元模型= y 有什么区别?y : '看' ; 和模型 = y ?'看' : ' '; 在 JavaScript 中?
- node.js - 将 express Response 转换为 http ServerResponse
- fasm - 任何人都知道 FASMW 中的 import kernel,\GetModuleHandle,'GetModuleHandleA',\ExitProcess,'ExitProcess' 是什么?PLS 海尔普
- c# - 如何使用 appsetting.json 上的配置为 ASP.Net Core 中的每个类任务创建单独的日志文件