3

I am having a client side built with angular (ssl enabled) and my server is not ssl enabled. I am getting a mixed content error. I searched for solution online but couldn't find anything that can help me to solve it. I am providing necessary information.

Component function :

 onSubmit(form:NgForm) {

       this.subscription = this._validation.validation({
            cell_no: form.value.cell_no, pass: form.value.password,
            username: this._common.getConnData().username, password:this._common.getConnData().password
        })
        .subscribe(res => {
             if(typeof res == 'string') // invalid access attempt
             {
                   this.invalid_access = true;
             }
             else // login successful 
             {    
                console.log(res);     
             }
        })
 }

Service function :

validation(data:{})
{
    const body = JSON.stringify(data);
    const headers = new Headers();      
    headers.append('Content-Type', 'application/json');

    return this._http.post(this._common.getBaseUrl()+"doctor_panel_api/validation_modified/format/json",
    body, {headers: headers})
    .map(res => res.json()); 
 }

I am getting following errors after clicking login button :enter image description here

The whole app works like a charm if I connect server from my localhost. Thanks in advance

Vadzim
  • 24,954
  • 11
  • 143
  • 151
Niaz Ahsan
  • 351
  • 1
  • 7
  • 21

1 Answers1

2

It can be due to your client is hosted on https(secure) but making request to http(unsecure). And your client and server hosted on different servers.

alexKhymenko
  • 5,450
  • 23
  • 40
  • 1
    Yes I know that. But I am looking for a solution. There can be another layer for solving this issue. But I need an optimal solution now. Thanks – Niaz Ahsan Sep 20 '17 at 05:39
  • 1
    The only solution that is possible is to create proxy server. That will host on the same domain as client and proxy request to real server. By the way its what angular -cli does. Thats why its working on localhost – alexKhymenko Sep 20 '17 at 05:53