I have this code in Angular2 TypeScript where I am trying to add headers like the following.
['access-token', localStorage.getItem( 'token' )],
['client', localStorage.getItem( 'client' )],
['uid', localStorage.getItem( 'email' )],
['withCredentials', 'true'],
['Accept', 'application/json'],
['Content-Type', 'application/json' ]
While sending the request I can't see the headers in my request. I am working on a cross domain setup. Is there some other way to do it?
private _request(url: string | Request, options?: RequestOptionsArgs) : Observable<Response> {
let request:any;
let reqOpts = options || {};
let index:any;
if(!reqOpts.headers) {
reqOpts.headers = new Headers();
}
for( index in this._config.authHeaders ) {
reqOpts.headers.set( this._config.authHeaders[index][0], this._config.authHeaders[index][1] );
}
request = this.http.request(url, reqOpts);
return request;
}

Access-Control-Allow-Headerson the server.