I'm trying to make a POST using VueJS 1.0.28 but I'm getting a Laravel 5.3 TokenMismatchException error.
This is in app.js to cover both jQuery and Vue:
Vue.http.interceptors.push((request, next) => {
request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);
next();
});
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
This is in the main.blade.php layout where we instantiate the Laravel value:
<script src="{!! asset('/js/app.js') !!}"></script>
<script>
(function () {
window.Laravel = {
csrfToken: '{{ csrf_token() }}'
};
})();
</script>
When I look at the headers in the POST request, I don't see the X-CSRF included for Vue.
This is super basic stuff for jQuery and I'm a stumped what I misconfigured on the Vue side. Ideas?