couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Bykov <m.by...@gmail.com>
Subject Re: unauthorized ajax PUT to other base
Date Thu, 08 Dec 2011 15:04:12 GMT
2011/12/8 Michael Bykov <m.bykov@gmail.com>:
> Hi,
>
> I am trying to ping parallel /counters base.
>
> default.ini:
>
> secure_rewrites = false
>
> rewrites:
>  {
>    "from":"/counter",
>    "to":"../../../counters",
>    "method":"PUT",
>    "query":{}
>  },
>
> ajax call:
>
>    pingCounter: function(obj){
>      console.log('ping: ');
>      $.ajax({
>        type: "PUT",
>        url: '/counter',
>        data: { page : obj },
>        dataType: 'json',
>        success: function(msg) {
>          console.log( "ping saved: " + msg );
>        }
>      });
>    }
>
> And in log I got
>
> 'PUT' /counters 401 <=== note correct 'counters' DB name, so rewrites works ok.
>
> But this error occurred: {"error":"unauthorized","reason":"You are not
> a server admin."}
>
> Where I should place my admin password for DB "counters" ? In rewrites
> rule? But how?
>
>
> --
> М.
>
> http://diglossa.ru
> xmpp://m.bykov@jabber.ru


I've got an answer, it works with

    pingCounter: function(obj){
      console.log('ping inner: '+inspect(obj));
      $.ajax({
        type: 'POST',
        url: '/counter',
        data: JSON.stringify(obj),
        dataType: 'json',
        contentType: 'application/json',
        success: function(msg) {
          console.log( "ping saved: " + msg );
        },
        error: function(msg) {
          console.log( "my ping error: "+msg);
        }
      });
    }



-- 
М.

http://diglossa.ru
xmpp://m.bykov@jabber.ru

Mime
View raw message