PouchDB中的CORS错误,在CouchDB中启用了CORS [英] CORS error in PouchDB with CORS enabled in CouchDB

查看:88
本文介绍了PouchDB中的CORS错误,在CouchDB中启用了CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CouchDB中启用了CORS:

I have CORS enabled in CouchDB:

我在Windows 8.1上运行该应用程序,并使用hapi.js为其提供服务。

I run the app on Windows 8.1, serving it with hapi.js.

一段时间后在Chrome中查看该错误消息,该错误消息出现在控制台中:

When viewing it in Chrome after a while this error message appears in the console:

Uncaught (in promise) CustomPouchError {status: 500, name: "unknown_error", message: "Database encountered an unknown error", error: true, toString: function}

Firefox终止访问CouchDB,例如:
http://127.0.0.1:5984/user_z_at_z_p_ch/?_nonce=1431328831527
然后报告交叉源请求被阻止。

Firefox aborts accessing CouchDB, for instance: http://127.0.0.1:5984/user_z_at_z_p_ch/?_nonce=1431328831527, then reports that a cross origin request was blocked.

我尝试运行add-cors-to-couchdb,但出现此错误:

I have tried to run add-cors-to-couchdb but I get this error:

PS C:\Users\alex> add-cors-to-couchdb
events.js:85
      throw er; // Unhandled 'error' event
        ^
Error: read ECONNRESET
    at exports._errnoException (util.js:746:11)
    at TCP.onread (net.js:559:26)


推荐答案

似乎我错过了一个标题在沙发上config.ini的cors部分中: x-csrf-token

it seems that I missed one header in the cors section of config.ini in couchdb: x-csrf-token

cors现在可以使用这些标头:

cors now works with these headers:

accept, authorization, content-type, origin, referer, x-csrf-token

我不知道为什么会发生这种情况,但是嘿:它有效

I have no idea why this happens but hey: it works

这篇关于PouchDB中的CORS错误,在CouchDB中启用了CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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