apache2 和 couchdb 在 apache2 上启用 cors
apache2 and couchdb enable cors on apache2
我想从 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 ^(.*)$ [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
但是我尝试的任何请求都没有指定 headers。
那么 body 可以告诉我如何正确使用 couchdb + apache 吗?
好的,第一个问题是我的 apache2 配置在重新安装 headers 后被破坏了。
我有第二个问题,通过将此添加到 /etc/couchdb/local.ini:
解决了
[httpd]
enable_cors = true
[cors]
origins = *
我想从 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 ^(.*)$ [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
但是我尝试的任何请求都没有指定 headers。 那么 body 可以告诉我如何正确使用 couchdb + apache 吗?
好的,第一个问题是我的 apache2 配置在重新安装 headers 后被破坏了。
我有第二个问题,通过将此添加到 /etc/couchdb/local.ini:
解决了[httpd]
enable_cors = true
[cors]
origins = *