【问题标题】:enable CORS on Iris Couch在 Iris Couch 上启用 CORS
【发布时间】:2015-04-12 14:36:45
【问题描述】:

按照instructions 为我的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 补丁。

谢谢。

【问题讨论】:

    标签: couchdb cors


    【解决方案1】:

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

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

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

    AngularJS 示例:

    $http({withCredentials: true, ...}).post(...)
    

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

        【解决方案3】:

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

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

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

        执行: 添加-cors-to-couchdb https://YOURDOMAIN.iriscouch.com:6984 -u 用户名 -p 密码

        结果: 成功

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

        【讨论】:

          猜你喜欢
          • 2014-12-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-11-16
          • 2019-05-23
          • 2014-10-31
          • 2019-03-21
          相关资源
          最近更新 更多