I'm using Laravel 5.5. When I send POST request from laravel blade. Then everything is ok:
$.post({
url: 'http://localhost/check',
data: {
_token: CSRF_TOKEN, // I have CSRF token variable above.
test: "it works"
}
})
But I want to send that request with socket.io > node.js > laravel :
socket.emit('checkPost', { token: CSRF_TOKEN });
index.js
socket.on('checkPost', function (csrf) {
request.post({
url: 'http://localhost/check',
form: {
_token: csrf.token,
test: "it works"
}
});
});
With ajax everything is ok. Here I got token missmatch. Why?
When I disable token verification in VerifyCsrfToken for /check route then node request works too.
How can I fix that? Maybe there is controller csrf check method? Then I'll check post csrf in controller.. Thanks in advance and sorry for my bad English.