我們遇到了來自API的冗餘和處理錯誤的問題。如果API響應200,那麼一切正常。然而,當API返回409,我們得到一個可愛:Restangular錯誤處理導致CORS問題?
的XMLHttpRequest無法加載https://開頭**令牌= *。請求的資源上沒有「Access-Control-Allow-Origin」標題。因此不允許訪問原產地'http://127.0.0.1:9000
'。從有效的崗位操作
響應頭:
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Authorization, Accept, X-Authorization, User-Agent, DNT, Cache-Control, X-Mx-ReqToken, Keep-Alive, If-Modified-Since
Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin:http://127.0.0.1:9000
Access-Control-Max-Age:1728000
Cache-Control:private, must-revalidate
Connection:keep-alive
Content-Type:text/html; charset=utf-8
Date:Fri, 29 Aug 2014 21:55:51 GMT
ETag:"*****"
Server:nginx/1.6.0
X-Frame-Options:SAMEORIGIN
X-Powered-By:HHVM/3.3.0-dev+2014.08.22
Response headers from a post operation with a 409 response captured from postman:
Cache-Control →no-cache
Connection →keep-alive
Content-Encoding →gzip
Content-Type →text/html; charset=utf-8
Date →Fri, 29 Aug 2014 21:56:59 GMT
Server →nginx/1.6.0
Transfer-Encoding →chunked
X-Frame-Options →SAMEORIGIN
X-Powered-By →HHVM/3.3.0-dev+2014.08.22
任何試圖趕上response.status或錯誤處理作爲
restangular docs results in this:
config: Object
data: ""
headers: function (name) {
status: 0
statusText: ""
概述我一直都爲0
狀態如果您需要查看任何其他信息,請告知我們。
非常感謝推送。這看起來像是一個開箱即用的**巨大的**限制,我無法理解爲什麼它默認爲這種行爲。我們最終在返回API中捕獲非成功代碼並手動設置CORS頭。似乎到目前爲止工作魅力。 – 2014-08-30 04:54:38