Recommended solution for AJAX, CORS, Chrome & HTTP error codes (401,403,404,500)

后端 未结 3 503
悲哀的现实
悲哀的现实 2020-12-25 08:29

Background

(If you are familiar with CORS, you might skip to the Question at the end)

CORS [1] is a solution to a

3条回答
  •  没有蜡笔的小新
    2020-12-25 08:58

    Just ran into this issue. Setting the HTTP headers for the 401 response did the trick for me. The library I was using wasn't doing this properly without some customization. e.g.:

      self.headers["Access-Control-Max-Age"] = '1728000'
      self.headers["Access-Control-Allow-Origin"] = "http://localhost:3001"
      self.headers["Access-Control-Allow-Methods"] = "ANY"
      self.headers["Access-Control-Allow-Credentials"] = 'true'
    

提交回复
热议问题