2

In my angular app, all the HTTP resources are automatically changed to https while fetching. I checked the server, and there are no automatic redirect settings configured to https.

The following are the errors I get in the console and the network tab.

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 In the console it says HTTP but in the network tab, it says HTTPS.

Request Code

constructor(private http: HttpClient) { }
     
 getHub( ): Observable<Hub> {
       
        return this.http.get<Hub>("http://xxxxxxxx-env.eba-prmacaby.ap-south-1.elasticbeanstalk.com/all/hub" );
      }
8
  • Can't see screenshots, could you please share error messages as text? Commented Oct 13, 2020 at 7:45
  • @shadowman_93 I edited the description with error text from the console. Commented Oct 13, 2020 at 7:51
  • Please check you IIS configuration, do you have configuretion like this? stackoverflow.com/a/38686154/5955138 Commented Oct 13, 2020 at 7:56
  • No, I don't have any such configs Commented Oct 13, 2020 at 8:01
  • Add your request code here, i cannot help you without some code. Commented Oct 13, 2020 at 8:25

2 Answers 2

0
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));
  }

Try it and show what are u expecting.

Sign up to request clarification or add additional context in comments.

4 Comments

It can't subscribe to the response as it fails due to the https on the URL. I subscribed to the error state and the exception is given below. It is the same as the exception I see on the browser HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "http:// xxxx-env.eba-prmacaby.ap-south-1.elasticbeanstalk.com/all/hub/", ok: false, …}
Have you added the HttpClientModule in the app.module.ts
Yes, there is no exception related to the code. My other HTTPS resources are loading fine.
Try to remove the Observable and write a pure method. getHub() { return this.http.get("http://xxxxxxxx-env.eba-prmacaby.ap-south-1.elasticbeanstalk.com/all/hub"); } Look if it works and remove the white space at the end of the all/hub because u have a space there.
0

Please check your CSP there if you have "upgrade-insecure-requests" you are upgrading your http requests to https requests.

Do not use following content attribute:-

meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.