I have a simple Rails 6 app where I use a form
<%= bootstrap_form_with(model: event, local: true, html: { multipart: true }) do |form| %>
In the generated HTML I have this is the header
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="SOME TOKEN" />
And in the form
<input type="hidden" name="authenticity_token" value="SOME OTHER TOKEN" />
Usually all works fine, but sometimes I get an error
Can't verify CSRF token authenticity.
The log shows be that the token has been passed in the parameters and I cannot find out why the validation fails. I ma sure that there is no malicious use or anything like that.
Are there any reasons why a CSRF token loses its validity? Maybe it's only valid for a certain time?