来自XMLHttpRequest的CouchDB跨域访问? [英] CouchDB cross-domain access from XMLHttpRequest?

查看:84
本文介绍了来自XMLHttpRequest的CouchDB跨域访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,Web应用程序需要提供某种跨域HTTP标头以访问其他域上的数据: http://openfontlibrary.org/wiki/Web_Font_linking_and_Cross-Origin_Resource_Sharing

Currently, web application need to offer some kind of cross-domain HTTP header to access data on other domain: http://openfontlibrary.org/wiki/Web_Font_linking_and_Cross-Origin_Resource_Sharing

是否可以将CouchDB配置为支持无限的跨域访问? (它可能在内部使用apache httpd)。我仅出于内部目的使用db。

Is there any way to configure CouchDB to support unlimited cross-domain access? (it may use apache httpd internally) I'm using the db in-house purpose only.

推荐答案

您可以使用CouchDB显示函数来设置Access-Control-Allow-Origin标头。

You could use a CouchDB show function to set the Access-Control-Allow-Origin header.


function(doc, req) {
  return {
    body : 'whatever',
    headers : {
      "Access-Control-Allow-Origin": "\"*\""
    }
  }
}

此处显示功能的更多信息: http://guide.couchdb.org/draft/show.html

More info on show functions here: http://guide.couchdb.org/draft/show.html

这篇关于来自XMLHttpRequest的CouchDB跨域访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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