【问题标题】:apache2 and couchdb enable cors on apache2apache2 和 couchdb 在 apache2 上启用 cors
【发布时间】:2016-04-12 03:57:47
【问题描述】:

我想使用来自 apache 网络服务器的 couchdb,要使用它,我必须向 couchdb 服务器发出 cors 请求。 所以我所做的是为 apache 创建一个新的 VirtualHost 配置,如下所示(localhost.maxbit89.conf):

<VirtualHost *:80>
        ServerAlias localhost.maxbit89
    ServerName localhost.maxbit89

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/localhost.maxbit89
    <Directory /var/www/localhost.maxbit89/>
        Options Indexes FollowSymLinks MultiViews
                AllowOverride None

        # Always set these headers.
        Header always set Access-Control-Allow-Origin "*"
        Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
        Header always set Access-Control-Max-Age "1000"
        Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"

        # Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
        RewriteEngine On
        RewriteCond %{REQUEST_METHOD} OPTIONS
        RewriteRule ^(.*)$ $1 [R=200,L]
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

但是我尝试的任何请求都没有指定的标头。 那么任何人都可以告诉我如何正确使用 couchdb + apache 吗?

【问题讨论】:

    标签: apache cors couchdb


    【解决方案1】:

    好的,第一个问题是我的 apache2 配置在重新安装 apache 后被破坏了头文件。

    我有第二个问题,通过将其添加到 /etc/couchdb/local.ini 解决了:

    [httpd]
    enable_cors = true
    
    [cors]
    origins = *
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-24
      • 1970-01-01
      • 1970-01-01
      • 2012-11-08
      • 2019-02-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多