Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

After update of React Admin Simple Rest Data Provider all requests return 416 Range Not Satisfiable

After updating ra-data-simple-rest from 3.3.2 to 3.10.4 every request to our API for lists started to fail with Error 416 Range Not Satisfiable. Backend did not change and we are still Allowing and returning Content-Range Header as prescribed by ReactAdmin documentation
ie:

headers: 
    {
    'Access-Control-Expose-Headers': 'Content-Range',
      'Content-Range': 'myresource 0-50/32'
    }
  }

I checked the source code of ReactAdmin Data Simple Rest and from my understanding, the change is related to adding another header Range because of some behavior in Chrome (see history of commits)

Since then though, all the queries made via ReactAdmin are failing in the browser due to Error 416 Range Not Satisfieble . Checking with CURL and Postman the request go through and contain every necessary header, properly exposed.

By manually removing that new Range header, just before sending the request with FetchUtils, the problem disappears.

After researching and trying out we found out that the Content-Range approach for pagination used by ReactAdmin was somehow hacky and it is best to use X-Total-Count .

We removed the Header ContentRange entirely, and used XTotalCount instead ( we specified the parameter in the dataProvider/httpclient as documented and the problem was gone.

What i dont understand is why was that happening. I cant see in the code anything that prevents me from still using Content-Range, and unfortunately I did not find any documentation in Changelog or Upgrade (nor Issues) that talk about the problem we had. So i am wondering if we were doing something wrong in our backend or in the way we use the provider, or the code has a bug which nobody experienced before.

question from:https://stackoverflow.com/questions/65901479/after-update-of-react-admin-simple-rest-data-provider-all-requests-return-416-ra

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...