(Softlayer, Open Stack Swift) How to solve cross domain origin with object storage api?

久未见 提交于 2019-12-13 01:59:02

问题


I used this document : http://docs.openstack.org/developer/swift/cors.html#test-cors-page

Used the below code, sends Option request and get 200 as the response. But the orginal method 'get' doesn't get response. And browser console says 'Access-Control-Allow-Origin' CORS header is not found.

$.ajax({
    method: "GET",
    url : url,
    crossDomain: true,
    headers: {
        'X-Container-Meta-Access-Control-Allow-Origin' : 'http://127.0.0.1:8080',
        'X-Container-Meta-Access-Control-Max-Age' : 10,
        'X-Auth-Token' : token
    },  
    contentType : 'application/json; charset=utf-8'
});

回答1:


If memory serves the SL Object Storage only support CORS on containers and not individual objects. The following headers should be supported:

X-Container-Meta-Access-Control-Allow-Origin
Origins to be allowed to make Cross Origin Requests, space separated.

X-Container-Meta-Access-Control-Max-Age
Max age for the Origin to hold the preflight results.

X-Container-Meta-Access-Control-Expose-Headers
Headers exposed to the user agent (e.g. browser) in the actual request response, space separated.



来源:https://stackoverflow.com/questions/36493793/softlayer-open-stack-swift-how-to-solve-cross-domain-origin-with-object-stora

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!