Skip to content

Adds a with credentials flag to all outgoing http requests.

Notifications You must be signed in to change notification settings

aarmora/angular-with-credentials

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

npm version

angular-with-credentials

angular-with-credentials is a simple service that you can use to easily add the withCredential flag to angular HTTP requests.

Install

npm install angular-with-credentials

How To Use

Import into your NgModule

import { CredentialsService } from 'angular-with-credentials';

...

@NgModule({
    providers: [
        CredentialsService,
        ...
    ]
})

Wherever your http calls are made:

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { CredentialsService } from 'angular-with-credentials';

@Injectable()
export class PizaService {
    constructor(
        private http: Http,
        private credentials: CredentialsService) {

        
        if (this.credentials) { // This is here to help with testing so you can pass in null for CredentialsService
            this.credentials.augmentXhrBuild((xhr: any) => {
                xhr.withCredentials = true;
            });
        }

    }

    // Any http calls you have

}

License

ISC License

About

Adds a with credentials flag to all outgoing http requests.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published