For my ionic.config.json , I have:
{ "name": "TSICMobile", "app_id": "6e4680fa", "typescript": true, "v2": true, "proxies": [ { "path": "/api", "proxyUrl": "http://192.168.0.105:8081/api" } ] }
In my provider ( user-data.ts , based on the Ionic2 conference application) I have, for example:
login(credentials) { return new Promise((resolve, reject) => { this.http.post( '/api/Login', JSON.stringify(credentials), { headers: this.contentHeader } ).subscribe(res => { console.log('api/Login return'); this.data = res.json(); if (this.data.authenticated === true) { this.storage.set('TSIC_USER_PROFILE', JSON.stringify(this.data.tsiC_USER_PROFILE)); this.storage.set('TSIC_USER_ROLES', JSON.stringify(this.data.listRoles)); this.storage.set('tsic_id_token', this.data.token); this.events.publish('user:login'); resolve(true); } else { reject('not authenticated'); } }, error => { console.log('api/Login failed'); reject(error); }); }); }
at startup:
ionic serve --lab -c
the proxy works fine and fits into http://192.168.0.105:8081/api/Login
at startup
ionic run android -c
post url file://api/Login , and obviously not executed.
I need help in understanding why (apparently) the proxy server does not work when working on the device and what I can do wrong or do not understand.
source share