How do I get the Auth token from a Laravel API and immediately use that token in an http/ajax/axios request?
JS / Client
Vue.axios.post('http://laravelApi:8000/here', {someData}).then(response->{
console.log(response.data);
});
PHP / API
route::post('/here', function(){
response...
});
Is there a favoured pattern for returning & re-posting the csrf-token? Can I define the headers differently between an initial request and subsequent requests that include the cors token?
Could I store the laravel_sesson &/or XSRF-TOKEN cookie from the first response and the include it with subsequent responses. Can anyone point me towards good resources or code examples?
I keep finding examples from laravel with vue deployed bundled on a single server/host and would like to find clarification on async implentation of csrf tokens. Thanks!
Edit: Lots of good answers around for this one, but not so many at the time of posting. CSRF token doesn't need to be generated at request-time but instead persists throughout session.