Skip to content

Instantly share code, notes, and snippets.

@smorcuend
Created March 8, 2016 12:02
Show Gist options
  • Save smorcuend/82eae3b50e5e896c81c3 to your computer and use it in GitHub Desktop.
Save smorcuend/82eae3b50e5e896c81c3 to your computer and use it in GitHub Desktop.
Angular2 feat(http): add support for withCredentials
import {BrowserXhr, HTTP_PROVIDERS} from "angular2/http";
import {Injectable, provide} from "angular2/core";
@Injectable()
class CORSBrowserXHR extends BrowserXhr{
build(): any{
var xhr:any = super.build();
xhr.withCredentials = true;
return xhr;
}
}
//...
//In your bootstrapped providers:
HTTP_PROVIDERS,
provide(BrowserXhr, {useClass: CORSBrowserXHR}),
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment