Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB vhost rewrite to access root API

Tags:

couchdb

I wish the following rewrite rule worked:

{
  "from": "api/*",
  "to": "../../../*"
}

… in a vhost rewrite like the following:

[vhosts]
myapp = /myapp/_design/myapp/_rewrite

Then it would be possible to access the root API in a following manner:

$.couch.urlPrefix = '/api';

var dbs = $.couch.allDbs({
  success: function (data) {
    console.log(data);
  }
})

But unfortunately the request to http://myapp:5984/api/_all_dbs results into:

{"error":"insecure_rewrite_rule","reason":"too many ../.. segments"}

Am I missing something? Is something wrong with the rewrite? Does anyone know how to overcome that? My Couchdb is 1.1.1.

I'm acquainted to this advice, but don't like any of the suggested ways.

like image 758
mcmlxxxiii Avatar asked Feb 18 '26 05:02

mcmlxxxiii


1 Answers

Add

[httpd]
secure_rewrites=false

to your server's local.ini to disable this protection from cross-database rewrites.

like image 103
Robert Newson Avatar answered Feb 21 '26 13:02

Robert Newson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!