{ "id": "api/common/http/HttpClientXsrfModule", "title": "HttpClientXsrfModule", "contents": "\n\n
\n
\n
\n \n API > @angular/common > @angular/common/http\n
\n \n
\n \n
\n

HttpClientXsrfModulelink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

Configures XSRF protection support for outgoing requests.

\n\n

See more...

\n
\n \n \n \n
\n\nclass HttpClientXsrfModule {\n static disable(): ModuleWithProviders<HttpClientXsrfModule>\n static withOptions(options: { cookieName?: string; headerName?: string; } = {}): ModuleWithProviders<HttpClientXsrfModule>\n}\n\n\n \n \n\n
\n\n\n \n\n \n \n \n
\n

Descriptionlink

\n

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

\n

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

\n\n \n
\n\n \n\n \n\n
\n

Static methodslink

\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n disable()\n \n link

\n \n
\n
\n

Disable the default XSRF protection.

\n\n
\n
\n \n\n static disable(): ModuleWithProviders<HttpClientXsrfModule>\n\n \n\n
Parameters
\n

There are no parameters.

\n\n \n
Returns
\n

ModuleWithProviders<HttpClientXsrfModule>

\n\n \n\n\n \n\n \n
\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n withOptions()\n \n link

\n \n
\n
\n

Configure XSRF protection.

\n\n
\n
\n \n\n static withOptions(options: { cookieName?: string; headerName?: string; } = {}): ModuleWithProviders<HttpClientXsrfModule>\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n
\n \n options\n object\n

An object that can specify either or both\ncookie name or header name.

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

Optional. Default is {}.

\n\n
\n\n \n
Returns
\n

ModuleWithProviders<HttpClientXsrfModule>

\n\n \n\n\n \n\n \n
\n
\n\n \n
\n\n \n\n \n\n\n \n\n\n \n \n
\n

Providerslink

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