javascript - 400 错误请求 http 调用角度
问题描述
您好我正在尝试访问此 url 以获取我的应用程序的令牌,但一直给我一个 400,我的应用程序的代理配置如下。
代理.conf:
"/token": {
"target": {
"host": "url",
"protocol": "https",
"port": 443
},
"secure": false,
"changeOrigin": true,
"logLevel":"info",
"pathRewrite": {
"^/token": "/auth/token"
}
}
这是检索令牌的函数:
private getAccessToken(): Observable<ArrayBuffer> {
const url = '/token';
const body = new HttpParams()
.set('client_id', 'daiga6')
.set('client_secret', 'aouwhyruhg8ag')
.set('grant_type', 'client_credentials');
const headers = new Headers({
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0',
Accept: '*/*',
'Accept-Language': 'es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate',
'Content-Type': 'application/x-www-form-urlencoded',
Connection: 'keep-alive',
Pragma: 'no-cache',
'Cache-Control': 'no-cache'
});
const options: any = {headers};
return this.http.post(url, body, options);
}
返回我的调用的错误消息如下:
错误请求 您的浏览器发送了此服务器无法理解的请求。原因:您对启用 SSL 的服务器端口使用纯 HTTP。请改用 HTTPS 方案访问此 URL。
有任何想法吗?
使用此配置,您可以解决它:
"/token": {
"target": {
"host": "url",
"protocol": "https:",
"port": 443
},
"secure": false,
"changeOrigin": true,
"logLevel":"info",
"pathRewrite": {
"^/token": "/auth/token"
}
}
解决方案
推荐阅读
- c# - WPF 绑定路径
- ios - MkMapView 崩溃 iOS
- web-scraping - 无法使用 scrapy-splash 抓取动态加载网页
- javascript - 使用 Material UI 中的 theme.breakpoints.down('') 时出错
- javascript - 如何使用 Angular 8 以编程方式选中或取消选中我的复选框?
- javascript - 如何在 JavaScript 中像时钟一样增加 8 位值的数组?
- python - 如何在 Pybullet 中加载 urdf.xacro?
- html - 为 2 个不同的对象生成相同的 2 种随机颜色
- java - Eclipse 未使用指定的 JDK
- javascript - 使用 svg 可调整大小的带有粗糙边缘的框