Ionic - HTTP GET remove default headers property

HI everyone,
I am using Ionic 3, and I get a problem with my application, every request have 1 header with content

X-Requested-With: com.app.myappid

So i want remove or disable this property. could you help me or give me 1 solution for this case. help me please

thank so much

      let headers = new Headers();
      headers.append('Content-Type', 'application/json');
1 Like

I try, but i get this message:
Refused to set unsafe header.

and, i think this is append header only, not remove, did you try it ago?

I tried it and it should work

import { Http, Headers } from '@angular/http';
constructor(public http: Http}
let headers = new Headers();
headers.append('Content-Type', 'application/json');
this.http.post('address', JSON.stringify(someData), { headers: headers })
              .map(res => res.json())
              .subscribe(data => {
                //something
              }, (err) => {
                //something
              });

Thanks, FnnHuman, but now iā€™m using this.http.get.

I think this problem is happened with this.http.get only.
do you have any solution for this case!

some one help me pls !

Where are you testing? Browser, emulator, device?
What is your ionic info output?

I using device, and capture request by proxy progam (burpsuite)
and on burpsuite i see one property in headers
X-Requested-With: com.app.myappid

and some Webserver filter this property and block me, i try to remove this property by burpsuite it working, so now, i want to disable this information in headers

Find out if the native app or the Angular code is adding the header. (test in browser, see if also present).
See if it is consistent on Android and iOS.

My guess: This is a default feature of the webview and will be not that easy to disable.

Thanks, my app is crawler data app, so, some time, server filter by block all request have this property:(!

Interesting, you are using Ionic as a base for a mobile crawler? Tell me more.

As I wrote, you will have to find out who exactly is adding this header. When you know, you can start searching for a workaround.

Yeah, I used for crawler, server block my app by this field!