Custom http headers


Hi, I’m trying to add a custom http header and the code works on android, but not on ios. I’m using HttpHeaders from @angular/common/http with the following code:

let headers = new HttpHeaders()
            .append('Content-Type', 'application/x-www-form-urlencoded')
            .append('X-Test-App-Version', 'my version text');

If I just set or append a single header then the header is set on iOS, but when more than 1 header is set iOS will not send the request. We also tried using the older Headers using @angular/http which had the same problem. Any help would be appreciated - thank you!


This is now resolved - the issue was because we were using

Which is good to do - but it’s more strict than the older UIWebView as it enforces CORS - see the link above.

To get our iOS app to work we had to get the server to accept the custom headers we were sending by setting ‘Access-Control-Allow-Headers’ server side.