1
當我使用ionic serve
時,我有一個Ionic 2應用程序和一個用於開發的代理用戶。所有與這在我的配置文件偉大的工作:離子2代理不再工作
"proxies": [
{
"path": "/apiv2/",
"proxyUrl": "https://myapilink.com/apiv2/"
}
]
在我離子提供商:
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);
});
});
}
當我跑我的離子項目,ionic serve
,我可以看到代理添加:
[09:54:50] Proxy added:/apiv2/ => https://myapilink.com/apiv2/
但是當我運行我的應用程序,當API調用來了,在我的網絡日誌中我只有500錯誤:
POST http://localhost:8100/apiv2/ 500 (Internal Server Error)
雖然Ionic服務器正在運行,但是如果我使用chrome並輸入此網址:http://localhost:8100/apiv2/
,我的API的結果是,我的JSON返回,因此重定向已完成。我不明白的地方它是從
感謝來提前爲任何幫助