【发布时间】: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 吗?
【问题讨论】: