4

按照说明为我的iriscouch启用 CORS :

  1. /_config/httpd/cors调成true
  2. 添加部分:/_config/cors/my.iriscouch.com:6984设置为"http://localhost http://myapp.com"

然后测试它:

$ curl -I https://my.iriscouch.com:6984/
HTTP/1.1 200 OK
Server: CouchDB/1.2.0 (Erlang OTP/R15B)
Date: Tue, 02 Oct 2012 10:49:18 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 40
Cache-Control: must-revalidate

响应中没有Access-Control-Allow-Origin标题...

还尝试重新启动服务器:

$ curl -XPOST -HContent-Type:application/json https://me:XXXX@my.iriscouch.com:6984/_restart
{"ok":true}

但没有更多的运气...

--

有没有人成功为他的 iriscouch 启用 CORS?

注意:我的帐户应该已经应用了 CORS 补丁。

谢谢你。

4

3 回答 3

4

我使用以下配置使其工作:

section | option      | value
-------------------------------
cors    | credentials | true
cors    | origins     | *
httpd   | enable_cors | true

此外,如果您从 web 应用程序执行任何 ajax 请求,请确保将 withCredentials参数设置为true

AngularJS 的示例:

$http({withCredentials: true, ...}).post(...)
于 2013-08-21T07:14:29.017 回答
2

如果您打开“配置”工具,您会在“ httpd ”下找到“ enable_cors ”。您想将该值更改为“ true ”。

接下来,如果您向下滚动到页面底部,您会发现一个“添加新部分”链接。您想单击它并在“ cors ”部分添加一个值为“ * ”的“ origins ”选项。您可以将“ origins ”值设置为实际 URL,但这将为每个人启用 CORS。

这就是我让它为我工作的方式。

于 2014-07-22T20:01:53.627 回答
1

看来这现在是可能的。虽然我还没有测试过,但我已经启用了 CORS。我刚开始玩 CouchDB。

检查配置。CORS 应显示已禁用。http://YOURDOMAIN.iriscouch.com/_utils/config.html

请参阅此处的说明以安装 add-cors-to-couchdb http://pouchdb.com/getting-started.html

执行:add-cors-to-couchdb https://YOURDOMAIN.iriscouch.com:6984 -u USERNAME -p PASSWORD

结果:成功

再次检查配置。应该显示 CORS 已启用。http://YOURDOMAIN.iriscouch.com/_utils/config.html

于 2015-04-12T06:36:45.863 回答