harikrish harikrish - 1 year ago 464
HTTP Question

angular2 xhrfields withcredentials true

I am trying to login to a system. In angular 1, there was ways to set


But i could not find a working sollution in angular2

export class LoginComponent {
constructor(public _router: Router, public http: Http, ) {


onSubmit(event,username,password) {
this.creds = {'Email': 'harikrishna@gmail.com','Password': '01010','RememberMe': true}
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json');

this.http.post('http://xyz/api/Users/Login', {}, this.creds)
.subscribe(res => {



Answer Source

AFAIK, right now (beta.1) the option is not available.

You have to work around it with something like this:

let _build = http._backend._browserXHR.build;

http._backend._browserXHR.build = () => {
  let _xhr =  _build();
  _xhr.withCredentials = true;
  return _xhr;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download