As a novice in front-end development, I am looking to incorporate CSRF tokens into certain requests within a frontend application. The app is built using Angular version 12.2.17, and I am following the guidelines outlined in the Angular documentation: https://angular.io/api/common/http/HttpClientXsrfModule
To implement this, I have added the interceptor in my code as shown below:
import {HTTP_INTERCEPTORS, HttpClientModule, HttpClientXsrfModule } from "@angular/common/http";
imports: [
...
HttpClientXsrfModule
],
providers: [
...
{ provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true }
],
However, upon adding the "HttpXsrfInterceptor" line, I encountered an error tooltip in IntelliJ:
TS2552: Cannot find name HttpXsrfInterceptor . Did you mean HTTP_INTERCEPTORS ?
What adjustments do I need to make to properly configure the HttpXsrfInterceptor?
What I have tried:
As an attempt to solve the issue, I modified the imports line to include:
import {HTTP_INTERCEPTORS, HttpClientModule, HttpClientXsrfModule, HttpXsrfInterceptor } from "@angular/common/http";
This change, however, resulted in another error message related to the mentioned line:
TS2724: "@angular/common/http" has no exported member named HttpXsrfInterceptor . Did you mean HTTP_INTERCEPTORS ?