I'm using an Inertia F/E so Blade directives aren't an option but when I grab the cookie with
export const getCookie = (name = 'XSRF-TOKEN') => {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
};
for POST and DELETE routes to attach to a header with
const response = await fetch(url, {
method,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-CSRF-TOKEN': getCookie()
},
it fails, I've also tried X-XSRF-TOKEN just to be thorough but that wasn't any better. Previously I had been simply including a _token plucked from React state but that's been a nightmare to keep in sync and I'd like to move toward something a bit more inline with how things are supposed to work