-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] useSanctumClient send an additional request to the /sanctum/csrf-cookie route on each request #88
Comments
Hey @Delaylaph, indeed you are right. Laravel documentation says that we have to request it once before the request and pass it for all subsequent ones. |
Sorry for the offtop, I have one more question. If I use ofetch interceptors, namely Example: <script setup>
const { data, error, execute, status } = await useAsyncData('register', () => client('/api/register', {
method: 'POST',
body: requestFields.value,
onRequest(ctx) { // breaks the logic => response: CSRF token mismatch.
console.log(ctx);
}
}));
<script> |
That's correct. Unfortunately, there is no way in |
Hey @Delaylaph, you can test |
Now it seems to work fine. Thanks |
Hi, thanks for this library.
I noticed that the client from
useSanctumClient
sends an extra request to the/sanctum/csrf-cookie
route on each request. But wouldn't it be more correct to check if the XSRF-TOKEN is in the cookies, and insert it into the header if it is? It seems to me that we should make one request to get a token and then send that token in the header in all subsequent requests, rather than getting a new token for each request. Am I wrong?Steps to reproduce the behavior:
For example, if I send this request many times, the /sanctum/csrf-cookie request will also always be sent.
Response in the dev tools(don't mind the error status):
Nuxt environment:
Module information
Complete configuration:
The text was updated successfully, but these errors were encountered: