微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rails 反应管理 | Access-Control-Expose-Headers X-Total-Count 错误

如何解决Rails 反应管理 | Access-Control-Expose-Headers X-Total-Count 错误

我已将 react-admin 连接到我的 Rails API,但出现此错误

The X-Total-Count header is missing in the HTTP Response. The jsonServer Data Provider expects responses for lists of resources to contain this header with the total number of results to build the pagination. If you are using CORS,did you declare X-Total-Count in the Access-Control-Expose-Headers header?

我已尝试对我的 ApplicationController.rb 进行以下更改

class ApplicationController < ActionController::API
  after_action :custom_headers

  def custom_headers
    response.set_header['Access-Control-Expose-Headers'] = 'X-Total-Count'
  end
end

虽然这不再给我以前的错误,但由于参数数量错误(预期为 2,收到 0),我现在收到内部服务器错误。我是否遗漏了一个步骤,或者是否有不同的方式将我的 API 连接到 react-admin

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。