(Softlayer,Open Stack Swift)如何使用对象存储API解决跨域起源? [英] (Softlayer, Open Stack Swift) How to solve cross domain origin with object storage api?
问题描述
我使用了此文档: http://docs.openstack .org/developer/swift/cors.html#test-cors-page
使用以下代码,发送Option请求并获得200作为响应. 但是原始方法"get"不会得到响应. 并且浏览器控制台显示未找到"Access-Control-Allow-Origin" CORS标头.
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'
});
推荐答案
如果内存用于SL对象存储,则仅支持容器上的CORS,而不支持单个对象.应该支持以下标头:
If memory serves the SL Object Storage only support CORS on containers and not individual objects. The following headers should be supported:
X容器元访问控制允许来源
允许起源发出交叉起源请求,以空格分隔.
X-Container-Meta-Access-Control-Allow-Origin
Origins to be allowed to make Cross Origin Requests, space separated.
X容器元访问控制最大年龄
Origin保留预检结果的最大年龄.
X-Container-Meta-Access-Control-Max-Age
Max age for the Origin to hold the preflight results.
X容器-元访问控制-暴露头标题
实际请求响应中显示给用户代理(例如浏览器)的标头,以空格分隔.
X-Container-Meta-Access-Control-Expose-Headers
Headers exposed to the user agent (e.g. browser) in the actual request response, space separated.
这篇关于(Softlayer,Open Stack Swift)如何使用对象存储API解决跨域起源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!