2017-05-30 5 views
1

Ich habe eine Ionic 2 App mit einem Proxy I Benutzer für die Entwicklung, wenn ich ionic serve verwende. Alle arbeiten gut mit in meiner Konfigurationsdatei:Ionic 2 Proxy funktioniert nicht mehr

"proxies": [ 
    { 
     "path": "/apiv2/", 
     "proxyUrl": "https://myapilink.com/apiv2/" 
    } 
] 

Und in meinem Ionic Anbieter:

constructor(public http: Http) { 
    this.API_URL = "/apiv2"; 
    this.data = {}; 
    } 

    call(action, entity, params){ 

     return new Promise(resolve => { 
      let link = this.API_URL; 
      let data = JSON.stringify({action: action, entity: entity, params: params}); 

      this.http.post(link, data) 
       .map(res => res.json()) 
       .subscribe(data => { 
        this.data = data; 
        resolve(this.data); 
       }, error => { 
        console.log(error); 
       }); 
     }); 
    } 

Als ich mein Ionic Projekt mit ionic serve laufe, kann ich sehen, dass die Proxys hinzugefügt:
[09:54:50] Proxy added:/apiv2/ => https://myapilink.com/apiv2/

Aber wenn ich meine app laufen, wenn ein API-Aufruf kommt, die ich in meinem Netzwerk Protokoll nur 500 Fehler haben:

POST http://localhost:8100/apiv2/ 500 (Internal Server Error) 

Aber während Ionic-Server ausgeführt wird, wenn ich auf Chrom gehe und diese URL eingeben: http://localhost:8100/apiv2/, habe ich das Ergebnis meiner API, mit meiner JSON-Rückgabe, so dass die Umleitung vorgenommen wird. Ich verstehe nicht, wo es für jede Hilfe von

Vielen Dank im Voraus kommen ist

Antwort

Verwandte Themen