apache2和couchdb在apache2上启用cors [英] apache2 and couchdb enable cors on apache2
问题描述
为什么我要使用apache网站服务器上的沙发床,要使用此文件,我必须向该沙发床服务器发出cors请求. 所以我要做的是为Apache创建一个新的VirtualHost配置,如下所示:(localhost.maxbit89.conf):
Hy I want to use couchdb from a apache webserver, to use this I have to make cors requests to the couchdb server. So what I did was creating a new VirtualHost config for apache that look like this(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
但是我尝试的任何请求都没有特定的标题. 那么,有谁能告诉我如何正确使用沙发床+ Apache?
But any request I tryed has non of the spezified headers. So can any body tell me how i use couchdb + apache the right way?
推荐答案
好吧,第一个问题是重新安装apache后,我的apache2配置如何被破坏了.
Ok first problem was some how my apache2 config was broken after reinstalling apache the headers were send.
我有第二个问题,可以通过将其添加到/etc/couchdb/local.ini来解决:
I had a second problem that was solved by adding this to /etc/couchdb/local.ini:
[httpd]
enable_cors = true
[cors]
origins = *
这篇关于apache2和couchdb在apache2上启用cors的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!