Skip to content

Commit cb692eb

Browse files
authored
Merge pull request #171 from youyoumu/docs/csrf-protection
Add note about X-XSRF-TOKEN header
2 parents 0f69e56 + 65a1a51 commit cb692eb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/guide/csrf-protection.md

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Axios automatically checks for the existence of an `XSRF-TOKEN` cookie. If it's
5757

5858
The easiest way to implement this is using server-side middleware. Simply include the `XSRF-TOKEN` cookie on each response, and then verify the token using the `X-XSRF-TOKEN` header sent in the requests from axios. (That's basically what `inertia_rails` does).
5959

60+
> [!NOTE]
61+
> `X-XSRF-TOKEN` header only works for [Inertia requests](/guide/the-protocol#inertia-responses). If you want to send a normal request you can use `X-CSRF-TOKEN` instead.
62+
6063
## Handling mismatches
6164

6265
When a CSRF token mismatch occurs, Rails raises the `ActionController::InvalidAuthenticityToken` error. Since that isn't a valid Inertia response, the error is shown in a modal.

0 commit comments

Comments
 (0)