HttpClient CSRF
Last updated
What is HttpClient CSRF?
HttpClient includes a built-in mechanism to prevent XSRF attacks. When making HTTP requests, an interceptor reads a token from a cookie (default name: XSRF-TOKEN) and sets it as an HTTP header (X-XSRF-TOKEN). Since only code running on your domain can read this cookie, the backend can verify that the HTTP request originates from your client application and not from an attacker.
However, HttpClient only handles the client-side aspect of XSRF protection. Your backend service must be configured to set the cookie for your page and verify that the header is present on all relevant requests. Without this backend configuration, Angular’s default XSRF protection will not be effective.
Free resources to learn HttpClient CSRF
More in stage 18: Developer Tools
- Developer Tools
- Angular CLI
- DevTools
- Local Setup
- Language Service
- Deployment
- Libraries
- End-to-End Testing
- Using Libraries
- Schematics
- Creating Libraries
- Build Environments
- Cross-site Scripting
- HTTP Vulnerabilities
- CLI Builders
- Sanitization
- Cross-site Request Forgery
- AoT Compilation
- Trusting Safe Values
- Enforce Trusted Types
- XSRF protection
- Cross-site Script Inclusion
- NGXS
- NgRx
- RxJS Interop
- Inputs as Signals
- Queries as Signals
- Model Inputs
HttpClient CSRF: common questions
Can I learn HttpClient CSRF in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain HttpClient CSRF in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this HttpClient CSRF tutorial for beginners?
It is lesson 113 of 158 in the free Angular roadmap, in stage 18, Developer Tools. If you are new to Angular, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.