I'm using Digital Ocean Load balancer to divide all the requests into 2 separated servers. Both servers are runing the same Laravel application, but when those 2 servers are online and i try to do a post request, sometimes i receive a status 419 and sometimes 200, but when 1 server is offline, the requests works normally
I suppose you are using the default session driver, which is files. Because of this your sessions are set on one of the server and the other server doesn't know of this session. The csrf token set on the form is created and checked using the current session for the visitor, if this request is posted to the other server you will receive an error 419 because this server has no knowledge of the session.
To solve this, you should use a session driver that can be shared between servers like database
, memcached
or redis
.