Completed 406 Not acceptable in development

I am integrating an ios application with a rails server. Here I implemented authentication. when a new person logs in from my application, I get the following error in my logs

Processing by Devise::RegistrationsController#create as JSON Parameters: {"password_confirmation"=>"[FILTERED]", "email"=>" sss@example.com ", "password"=>"[FILTERED]", "registration"=>{"password_confirmation"=>"[FILTERED]", "email"=>" sss@example.com ", "password"=>"[FILTERED]"}} WARNING: Can't verify CSRF token authenticity (0.1ms) begin transaction (0.0ms) rollback transaction Completed 406 Not Acceptable in 28ms (ActiveRecord: 0.7ms) 
+6
source share
2 answers

Deny json response has been removed from version 2.2 by default, so add

 respond_to :json 

in your application controller or specific controller where you want to answer json.

+11
source

Do not allow json reception for all controllers, but only for add development

 config.to_prepare do DeviseController.respond_to :html, :json end 

only up to config/application.rb as recommended here https://github.com/plataformatec/devise/issues/2209

+2
source

Source: https://habr.com/ru/post/951294/


All Articles