This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

HttpClientXsrfModule

Configures XSRF protection support for outgoing requests.

See more...

      
      class HttpClientXsrfModule {
  static disable(): ModuleWithProviders
  static withOptions(options: {...}): ModuleWithProviders
}
    

Description

For a server that supports a cookie-based XSRF protection system, use directly to configure XSRF protection with the correct cookie and header names.

If no names are supplied, the default cookie name is XSRF-TOKEN and the default header name is X-XSRF-TOKEN.

Static methods

Disable the default XSRF protection.

static disable(): ModuleWithProviders
      
      static disable(): ModuleWithProviders
    

Parameters

There are no parameters.

Returns

ModuleWithProviders

Configure XSRF protection.

static withOptions(options: { cookieName?: string; headerName?: string; } = {}): ModuleWithProviders
      
      static withOptions(options: {
    cookieName?: string;
    headerName?: string;
} = {}): ModuleWithProviders
    

Parameters

options

An object that can specify either or both cookie name or header name.

  • Cookie name default is XSRF-TOKEN.
  • Header name default is X-XSRF-TOKEN.

Optional. Default is {}.

Returns

ModuleWithProviders

Providers

Provider
HttpXsrfInterceptor
      
      HttpXsrfInterceptor
    
{ provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true }
      
      { provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true }
    
{ provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor }
      
      { provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor }
    
{ provide: XSRF_COOKIE_NAME, useValue: 'XSRF-TOKEN' }
      
      { provide: XSRF_COOKIE_NAME, useValue: 'XSRF-TOKEN' }
    
{ provide: XSRF_HEADER_NAME, useValue: 'X-XSRF-TOKEN' }
      
      { provide: XSRF_HEADER_NAME, useValue: 'X-XSRF-TOKEN' }