问题描述
在我的角度应用程序中,所有HTTP资源在获取时都会自动更改为https。我检查了服务器,并且没有将自动重定向设置配置为https。
core.js:3864 ERROR
HttpErrorResponse {headers: HttpHeaders,status: 0,statusText: "UnkNown Error",url: "http://xxxxxx-env.eba-prmacaby.ap-south-1.elasticbeanstalk.com/all/hub/",ok: false,…}
error: ProgressEvent {isTrusted: true,lengthComputable: false,loaded: 0,total: 0,type: "error",…}
headers: HttpHeaders {normalizednames: Map(0),lazyUpdate: null,headers: Map(0)}
message: "Http failure response for http://xxxxx-env.eba-prmacaby.ap-south-1.elasticbeanstalk.com/all/hub/: 0 UnkNown Error"
name: "HttpErrorResponse"
ok: false
status: 0
statusText: "UnkNown Error"
url: "http://xxxxxx-env.eba-prmacaby.ap-south-1.elasticbeanstalk.com/all/hub/"
__proto__: HttpResponseBase
在控制台中,它显示HTTP,而在“网络”标签中,它显示HTTPS。
请求代码
constructor(private http: HttpClient) { }
getHub( ): Observable<Hub> {
return this.http.get<Hub>("http://xxxxxxxx-env.eba-prmacaby.ap-south-1.elasticbeanstalk.com/all/hub" );
}
解决方法
getHub(): Observable<Hub> {
return this.http.get<Hub>("http://xxxxxxxx-env.eba-prmacaby.ap-south-1.elasticbeanstalk.com/all/hub" ).subscribe(test => console.log(test));
}
尝试一下,并显示您的期望。