0

I am able to login and logout most of the time, but sometimes during logging out I am returned with this error as stated below and I am not logged out.

Can't verify CSRF token authenticity.
User excluded error: #<ActionController::InvalidAuthenticityToken: ActionController::InvalidAuthenticityToken>

It doesn't happen always that I am not able to logout but when I am not able to logout above is the error which I get. I read about it this is what I have done so far. I am using vuejs on my front end and rails on the backend. I am using rails version 5.1.

application_controller.rb

protect_from_forgery with: :exception

application.html.erb

<%= csrf_meta_tags %>

this is the axios request I am making to logout the user

index.vue

logout() {
 this.$axios.delete('/users/sign_out').then(function(response) {
  console.log("Logged out")
 });
}

Please help me resolve this issue

Eyeslandic
  • 14,553
  • 13
  • 41
  • 54
user12763413
  • 1,177
  • 3
  • 18
  • 53

1 Answers1

0

You may need to add the csrf_meta_tags to the request

In your case, the csrf_meta_tags in application.html.erb is not re-rendered.