I am getting this CSRF token error and when I look around everyone just said that all I need is to use {{ csrf_field() }} when I submit my data. In the past, it was working fine but after some time, I got this error and I can't submit my data or even edit my data at all. Can someone help me here thanks.
Please tell me where did I go wrong? What am I suppose to do here
edit.blade.php (this is the csrf part)
<form class="form-horizontal" method="post" action="{{ url('/user/show/'.$object->id) }}">
{{ method_field('PUT') }}
{{ csrf_field() }}
<div class="input-group">
<label><b>Name/NRIC:</b></label>
<input type="text" name="Name" value="{{ $object->Name }}" class="form-control">
</div>
</form>
app.js (laravel default not mine, this is what I saw)
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
window.axios = __webpack_require__(16);
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
/**
* Next we will register the CSRF Token as a common header with Axios so that
* all outgoing HTTP requests automatically have it attached. This is just
* a simple convenience so we don't have to attach every token manually.
*/
var token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
EDIT: Not sure if this is related but since it is the login part just want to know if it affects this.
I have actually 2 app.blade.php for the layout so was wondering is that the reason which is causing this whole problems?
