CouchDB + 凭证 + 原始通配符的 CORS 问题 [英] CORS issue with CouchDB + credentials + origin wildcard

查看:17
本文介绍了CouchDB + 凭证 + 原始通配符的 CORS 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 flow.ch 上从 Cloudant 迁移到 Jelastic.在本地测试(离子服务)时,我收到 pouchdb 的 CORS 错误.

除了我缺少的 CouchDB 之外,Jelastic 中还有其他配置吗?

<块引用>

XMLHttpRequest 无法加载

  • 可以通过 CURL 正常访问.从 Cloudant 复制到 Jelastic 也同样有效.

  • 我尝试使用 Chrome 扩展来启用Allow-Control-Allow-Origin: *"

  • 解决方案

    couchdb 文档这样说:

    <块引用>

    您不能同时设置 origins = *credentials = true 选项

    因此,如果您希望具有凭据的跨域请求与 couchdb 一起使用,则必须将 origins 值设置为允许的来源的显式列表;例如:

    [cors]起源 = http://localhost, https://localhost, http://couch.mydev.name:8080

    I am trying to move from Cloudant to Jelastic on flow.ch. I am getting CORS errors with pouchdb when testing locally (ionic serve).

    Is there any other configuration in Jelastic besides CouchDB I am missing?

    XMLHttpRequest cannot load http://xxx.flow.ch/xxx. Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:8100' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

    1. I configured a CouchDB on Jelastic and activated CORS.

    2. Normal access via CURL works. Replication from Cloudant to Jelastic worked as well.

    3. I tried to use a Chrome extension to enable "Allow-Control-Allow-Origin: *"

    解决方案

    The couchdb docs say this:

    You can’t set origins = * and credentials = true option at the same time

    So if you want cross-origin requests with credentials to work with couchdb, you must set the origins value to an explicit list of allowed origins; for example:

    [cors]
    origins = http://localhost, https://localhost, http://couch.mydev.name:8080
    

    这篇关于CouchDB + 凭证 + 原始通配符的 CORS 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆