-
Hello, today I was experimenting with headless Laravel using Sanctum and Fortify. My plan was to do some basic testing of the auth flow before embarking on a Next.js frontend to consume the Laravel API. I'm on the latest version of Laravel, developing locally using Sail. Anyway, I was reading about the Sanctum workflow and getting stuck after trying to hit the Laravel Fortify
and
I was using the fetch API, including credentials, meaning I saw in the subsequent call to my Here is the relevant framework code: If at the bottom of that (above
Without this intervention, I would have to get the cookie in javascript and add it to the header, like this:
So my question is, why is this necessary? I know |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ok nvm I did some more framework agnostic research and I think I understand why this is done now. https://en.wikipedia.org/wiki/Cross-site_request_forgery#Cookie-to-header_token Because if it just read the cookie that would ruin the point of CSRF protection. |
Beta Was this translation helpful? Give feedback.
Ok nvm I did some more framework agnostic research and I think I understand why this is done now.
https://en.wikipedia.org/wiki/Cross-site_request_forgery#Cookie-to-header_token
Because if it just read the cookie that would ruin the point of CSRF protection.