NestJS HTTPModule 使用 Axios 获取请求总是得到 https 的 400

问题描述 投票:0回答:1

NestJS 现在使用 Axios 进行请求。当我尝试使用 https 进行简单的 Get 请求时,它总是返回 400 错误。

app.service.ts

getGithubDetails(): Observable<AxiosResponse> {
    return this.httpService.get('https://api.github.com/users/bwizrd');
}

app.controller.ts

@Get()
getGithubDetails(): any {
  return this.appService.getGithubDetails().pipe(
   map(response => response.data)
  )
}

对 HTTP 的 get 请求工作正常,但对 HTTPS 总是返回 400。我错过了什么? 同样的请求在 Postman 中工作得很好。

typescript axios nestjs
1个回答
0
投票

回到这个问题。我位于代理后面,该代理不允许 axios 作为客户端发出请求。配置代理后,它就可以正常工作了。

© www.soinside.com 2019 - 2024. All rights reserved.