I'm using angular2-rc4 with spring rest. I'm using spring authentication.
Spring authentication expects content-type to be application/x-www-form-urlencoded; charset=UTF-8 and post data in plain string format like "j_username=user&j_password=pass".
So I wrote the following code:
let data = 'j_username=user&j_password=password'; //Spring authentication expects data in this format.
let headers = new Headers({'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8'});
let options = new RequestOptions({headers: headers});
this.http.post(url, data, options).subscribe(
.....
....
);
When i execute this code through firefox, it going through without any issue. Data is reaching to server and authentication is working fine.
But when I do from chrome, its not working. Username and password are reaching to server with empty values.
I compared the request header of both chrome and firefox with the help of firebug. I noticed one difference. content-type is going properly in firefox but not in chrome. Below is the content type of both chrome and firefox:
Firefox: Content-type: application/x-www-form-urlencoded; charset=UTF-8
Chrome : Content-type: test/plain, application/x-www-form-urlencoded; charset=UTF-8
If you see chrome is automatically appending text/plain to its header. I'm not getting the reason behind this.
Note: This code was working with angular2-rc1. Started facing issue after upgrading to rc4.
Please help
Thanks