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
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?
Ok first problem was some how my apache2 config was broken after reinstalling apache the headers were send.
I had a second problem that was solved by adding this to /etc/couchdb/local.ini:
[httpd]
enable_cors = true
[cors]
origins = *
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.