I have the following problem:
In my angular service for retrieving data from an PHP script the browser or angular switches from https to http. My site is loaded over HTTPS with HTS so the ajax request is blocked as mixed content.
I have the following code for my ajax service:
import { Injectable, } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class AjaxService {
private apiUrl: string = "https://example.com/myapi/myscript";
/**
* @param {Http} http HTTPService
*/
constructor(private http: Http) { }
/**
* @param {string} piece
*/
public getAllComponents(piece: string) {
console.debug("Get Components for Query: " + piece);
return this.http.get(this.apiUrl + "?compontent=" + piece).map((res: Response) => res.json());
}
[...]
}
When i call my page from the main page https://example.com/Angular2Application and fire an request my browser tell me the ajax request was blocked for mixed content and tells me he tried to connect to http://example.com/myapi/myscript