Set x-xsrf-token and send it in header during request RTK Query #3034
Neo363
started this conversation in
Community Recipes
Replies: 2 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
-
I have a similar issue with the csrf token not being recognized by the database when I send the request |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have Laravel API + NextJs application with Sanctum authentication.
With Sanctum before sending request to the route, you need to send a request to /sanctum/csrf-cookie 'to initialize csrf protection'.
Here i how my RTK Query API looks:
Here is how the functions are called:
The logic works fine but i wanted to use only RTK Query and not depend on axios. Also, is there any way to handle getting the csrf-cookie and send it during the request from
createAPI()
?Beta Was this translation helpful? Give feedback.
All reactions