Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229350

CORS issue on real device

$
0
0

Hello,
I’ve added proxy in ionic.config.json and also checked platform and based on my platform am changing API url but seems CORS issue is not fixed for me.

ionic.config.json

{
  "name": "eppm",
  "app_id": "",
  "type": "ionic-angular",
  "integrations": {
    "cordova": {}
  },
  "proxies": [
    {
      "path": "/path",
      "proxyUrl": "http://domain/path"
    }
  ]
}

Api-manager.ts

import { Platform } from 'ionic-angular';
@Injectable()
export class ApiManagerProvider {
url:string;
constructor(private platform: Platform, public http: HttpClient, private cManager: CookieManagerProvider) { }
 private makePostRequest(command: string, data: any) {

    if(this.platform.is('core') || this.platform.is('mobileweb')) {
      url = 'pace/rest/3.0/eppm/cmd/';
      console.log("Web");
    }
    else {
      url = 'http://vs2.paramatrix.com:8764/pace/rest/3.0/eppm/cmd/';
      console.log("Mobile");
    }

    let apiHeader = new HttpHeaders();
    let contentType = apiHeader.set('Content-Type', 'application/x-www-form-urlencoded');
    let pace = contentType.append('pace-useragent', 'rest');

    let param = new URLSearchParams();
    for (var key in data) {
      param.append(key, data[key]);
    }

    return new Promise((resolve, reject) => {
      this.http.post(this.url + command, param.toString(), { headers: pace, withCredentials: true }).subscribe(res => {
        resolve(res);
      }, (error: HttpErrorResponse) => {
        reject(error);
      });
    });
  }
}

config.xml

<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

Kindly help me to figure this out guys.
Thanks in advance.


Viewing all articles
Browse latest Browse all 229350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>