这个设计配置有什么作用?

Spi*_*ion 3 ruby-on-rails devise

我想将设计限制为来自互联网的 api 上的 json 请求。它有什么作用?

# config/initializers/devise.rb

config.http_authenticatable_on_xhr = false
config.navigational_formats = ["*/", :html, :json]
Run Code Online (Sandbox Code Playgroud)

ush*_*sha 5

从设计文档,

config.http_authenticable_on_xhr = true

If http headers should be returned for AJAX requests. True by default.
Run Code Online (Sandbox Code Playgroud)

config.navigational_formats = [" / ", :html, :json]

==> 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 :"*/*" and "*/*" formats below is required to match Internet
   Explorer requests.
Run Code Online (Sandbox Code Playgroud)