Angular自动将http更改为https以加载资源

问题描述

在我的角度应用程序中,所有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

enter image description here

enter image description here

在控制台中,它显示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));
  }

尝试一下,并显示您的期望。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...