POST request내 로컬 개발자에게 다음과 같이 만들고 싶습니다.
HTTParty.post('http://localhost:3000/fetch_heroku',
:body => {:type => 'product'},)
그러나 서버 콘솔에서보고합니다.
Started POST "/fetch_heroku" for 127.0.0.1 at 2016-02-03 23:33:39 +0800
ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by AdminController#fetch_heroku as */*
Parameters: {"type"=>"product"}
Can't verify CSRF token authenticity
Completed 422 Unprocessable Entity in 1ms
여기 내 컨트롤러와 경로 설정이 있습니다. 매우 간단합니다.
def fetch_heroku
if params[:type] == 'product'
flash[:alert] = 'Fetch Product From Heroku'
Heroku.get_product
end
end
post 'fetch_heroku' => 'admin#fetch_heroku'
무엇을해야하는지 잘 모르겠습니까? CSRF를 끄는 것은 확실히 효과가 있지만 그러한 API를 만들 때 내 실수라고 생각합니다.
수행해야하는 다른 설정이 있습니까?
protect_from_forgery with: :null_session.