401 when access to /admin with JSON-API backend by Rails
症状
何事も無ければ、active_adminを使っている場合、/adminにアクセスしたら、以下の様な画面が見れるはずです。
しかし、今回こんな感じになりました。
Started GET "/admin" for ::1 at 2015-05-12 18:06:23 +0900 Processing by Admin::DashboardController#index as HTML Completed 401 Unauthorized in 0ms
原因
Deviseを認証に利用しようとして、設定ミスをしていました。
# ==> Navigation configuration # Lists the formats that should be treated as navigational. Formats like # :html, should redirect to the sign in page when the user does not have # access, but formats like :xml or :json, should return 401. # # If you have any extra navigational formats, like :iphone or :mobile, you # should add them to the navigational formats lists. # # The "*/*" below is required to match Internet Explorer requests. config.navigational_formats = ['*/*', :json]
↓にしたら直りました。
config.navigational_formats = ['*/*', :json, :html]