incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CGS <cgsmcml...@gmail.com>
Subject Re: Call to View returns 405. It's using OPTIONS not GET
Date Mon, 21 May 2012 14:00:22 GMT
Question: web server on port 80 and CouchDB on port 5489, how can I call
the CouchDB?
Answer: set a reverse proxy in your web server to serve certain requests to
CouchDB (e.g., the requests for http://test/couchdb to be redirected to
http://test:5489/).

Question: does the choice of browser affect this?
Answer: no, that's a security fix which protects web severs proprietary
rights (you wouldn't like your web pages to be integrated in another's
website, would you?).

Firefox has the same tools Google Chrome has. Just check the Firebug add-on.

CGS




On Mon, May 21, 2012 at 3:39 PM, Hankey, Chris <
Chris.Hankey@transamerica.com> wrote:

> Another question then.  If my page is being served on port 80 on server
> "test" & couchDB is on the default 5489 port, also on server "test",  then
> how do I call couch?  It seems that if I set the urlPrefix property with
> the 5489 port then I get the 405 error.  But if I don't set property then
> couch uses a GET but calls port 80.
>
> //this line causes a 405, but commenting out this line sends couch to port
> 80
> $.couch.urlPrefix ="http://test:5984"
>
> Does my choice of browsers affect this?  I'm using Chrome because I like
> the developer tools that come with it.
>
>
> -----Original Message-----
> From: Jim Klo [mailto:jim.klo@sri.com]
> Sent: Sunday, May 20, 2012 1:03 AM
> To: <user@couchdb.apache.org>
> Cc: <user@couchdb.apache.org>
> Subject: Re: Call to View returns 405. It's using OPTIONS not GET
>
> And if I had scrolled down further and put 2 and 2 together. You must be
> making a cross origin request. If OPTIONS is returning with 405 the address
> in the browser is different than your CouchDB. More on Cross Origin
> Resource Sharing here: http://www.w3.org/TR/cors/
>
> AFAIK CouchDB still doesn't support CORS except via JSONP which you can
> enable (I hear it's on a wish list tho!). However, I don't think the
> jquery.couch yet supports JSONP either. If you need to do XSS then, I
> remember hacking it a while back to support JSONP
> https://github.com/jimklo/lrchart/blob/master/lr-stats/_attachments/scripts/jquery.couch-patched.jsbut
don't recall how complete it is.
>
> There's a list and show function modification that can be made to support
> CORS, but not sure where that snippet lives in the Internet ether.
>
> - Jim
>
>
>
> Sent from my iPad
>
> On May 19, 2012, at 9:19 PM, "Jim Klo" <jim.klo@sri.com> wrote:
>
> > An OPTIONS request is made by your browser when you make a Cross Origin
> Request. Is your App on the same domain and port as CouchDB?
> >
> > Sent from my iPad
> >
> > On May 19, 2012, at 3:51 PM, "Hankey, Chris"
> <Chris.Hankey@Transamerica.com> wrote:
> >
> >> This is just some more info.  Where is "OPTIONS" coming from?  It looks
> like the view function tries to use GET, but we end up with OPTIONS.
> >>
> >> OPTIONS http://test:5984/forms/_design/formlist/_view/formlist HTTP/1.1
> >> Host: test:5984
> >> Connection: keep-alive
> >> Access-Control-Request-Method: GET
> >> Origin: null
> >> User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML,
> like Gecko) Chrome/18.0.1025.168 Safari/535.19
> >> Access-Control-Request-Headers: origin, content-type, accept
> >> Accept: */*
> >> Accept-Encoding: gzip,deflate,sdch
> >> Accept-Language: en-US,en;q=0.8
> >> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
> >>
> >>
> >> -----Original Message-----
> >> From: Hankey, Chris [mailto:Chris.Hankey@Transamerica.com]
> >> Sent: Saturday, May 19, 2012 5:54 PM
> >> To: user@couchdb.apache.org
> >> Subject: Call to View returns 405. It's using OPTIONS not GET
> >>
> >> I'm trying to call a view using the CouchDB Javascript API.  The
> $db.view call is failing with a "405 Method Not Allowed" error.  $db.view
> is generating the correct URL, but the call appears to be failing because
> the view function is using HTTP OPTIONS method ( or maybe JQuery).  If I
> change the HTTP method to GET & manually send the HTTP request, then it
> works fine.  I need $db.view to generate a GET.  Any thoughts?
> >>
> >> Thanks
> >>
> >> Chris
> >>
> >> -----------
> >> Sample Code
> >> -----------
> >>
> >> $.couch.urlPrefix ="http://test:5984"
> >> $db = $.couch.db("forms");
> >>
> >>
> >> function GetFormList() {
> >>  $("div#forms").empty();
> >>  $db.view("formviews/formlist", {
> >>   success: function(data) {
> >>    for (i in data.rows) {
> >>     id = data.rows[i].id;
> >>     html = '<div class="form">' +
> >>      '<span class="form">' + id + '</span> ' +
> >>      '<a href="#" class="edit">edit</a> '+
> >>      '<a href="#" class="delete">delete</a> '+
> >>      '</div>';
> >>     $("div#forms").append(html);
> >>    }
> >>  }});
> >> }
> >>
> >>
> >>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message