0.1.17 per-request header configuration doesn't work
Assuming the default configuration (AUTH_HTTP_PROVIDERS)
const BASE_REQ_OPTS = new RequestOptions({
headers: new Headers({ 'Content-Type': 'application/json' })
});
this.authHttp.post(
ENDPOINT,
JSON.stringify(<Your Object>),
BASE_REQ_OPTS
).map(res => res.json())
this will cause the post to be sent with a content-type of 'text/plain' (I believe the default http request type), whatever options you pass during the request.
0.1.16 functions as expected
We've encountered a similar problem since upgrading from version 0.1.16 to 0.1.1.17.
We create a HTTP POST request and set the Content-Type to application/json, however when the request is executed we can see the Content-Type is text/plain. Rolling back to 0.1.16 for now.
Experiencing the same thing. I rolled back to 0.1.15
Although I’ve update this module to 0.1.18, I have the same problem still. It seems to ignore header configuration.
@lazyhoneyant can you show how you're configuring your headers?
Below code is used in ionic2 framework. Previous version of angular2-jwt is working well. But after upgrade to latest version, It doesn't work as i said. No matter what I do, Content-type in Request header is 'text/plain'. thanks.
let apiUrl = 'http://';
let headers = new Headers({ 'Content-Type':'application/json'});
let options = new RequestOptions({headers:headers});
return this.authHttp.put(apiUrl, JSON.stringify({data:'test'}), options)
.map(this.extractData)
.catch(this.handleError);
Instead of providing a RequestOptions, can you try providing your headers object directly?
let apiUrl = 'http://';
let headers = new Headers({ 'Content-Type':'application/json'});
return this.authHttp.put(apiUrl, JSON.stringify({data:'test'}), { headers })
.map(this.extractData)
.catch(this.handleError);
Thanks for answering. I’ve checked and installed all of things again. Then It works well now.