0

Angular HTTP request is blocked - Showing mixed content.

But when i'm accessing through browser URL, the content is showing.

The angular code is:

            $http.post('http://crms.ttteamthoi.in/get_timespent_br', {
                'from': '01/11/2015',
                'to': '25/11/2015'
            }, {
                "headers": {
                    "Content-Type": "application/json; charset=UTF-8"
                }
            })
            .then(function(response) {
              //code here
            }

The console error showing is:

Mixed Content: The page at 'https://dash-thaidash.c9users.io/#/app/tonnage' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://crms.ttteamthoi.in/get_timespent_br'. This request has been blocked; the content must be served over HTTPS.

Is this angular specific?

Husni Abdul Nazer
  • 103
  • 1
  • 1
  • 12
  • Do you have access to the controller code or is this a third party? It seems also that it has detected you are making and ajax request and does not accept it as secure... – alexandra Dec 16 '15 at 07:11
  • I'm using this code in my controller. Does this ajax request only accepts secure ones? – Husni Abdul Nazer Dec 16 '15 at 07:16
  • I meant to ask if you have access to the code executed at 'http://crms.ttteamthoi.in/get_timespent_br' this route. It can check how the request is made and weather it is ajax or not and interpret this. – alexandra Dec 16 '15 at 23:00
  • The server is written in asp.net. Unfortunately i dont have access to it. Its a third party application. But the link is working fine when accessing through browser and even in hurl.it – Husni Abdul Nazer Dec 17 '15 at 09:36
  • So it seems from the request and the answers that the thirs party does not accept the ajax request. This is sometimes implemented in sonata. – alexandra Dec 17 '15 at 21:13
  • Thanks! that was the problem. – Husni Abdul Nazer Dec 18 '15 at 09:50

2 Answers2

2

Problem Solved.

Server is asp.net application without SSL. The call was from https://c9.io which is secure. That was the mixed content error.

Changing the server application to SSL & then enabling CORS for content type did the trick.

Husni Abdul Nazer
  • 103
  • 1
  • 1
  • 12
1

It does not seem to be Angular specific. crms.ttteamthoi.in host is telling you that accepts only https requests, but you POST some data using http protocol. Try using https.

You can simulate http requests here.

Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
  • I used https, but its a SSL ERROR. im getting the content while accessing the link through browser. – Husni Abdul Nazer Dec 16 '15 at 07:17
  • Hey, i'm getting the response in Hurl.it. Response: Cache-Control: private, max-age=0 Content-Length: 3373 Content-Type: application/json; charset=utf-8 Date: Wed, 16 Dec 2015 07:20:27 GMT Server: Microsoft-IIS/7.5 X-Aspnet-Version: 4.0.30319 X-Powered-By: ASP.NET – Husni Abdul Nazer Dec 16 '15 at 07:20