You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Wojciech Kaczmarek <ka...@gmail.com> on 2009/06/09 19:17:26 UTC

workaround for cross-site PUTs

Hi!

I'm going to hack a Greasemonkey script which would automatically
update CouchDB docs from a webpage content. It needs to be done at the
browser side, server side is out of reach for modification.

I can't use XMLHttpRequest as it doesn't allow cross-site requests.
When using jQuery's ajax with jsonp (or whatever application of script
tag injection) the requests are limited to GETs. So I'm going to have
a layer in the CouchDB translating external GETs to document-writing
PUTs.

Is couchapp able to do this with some of its helpers or should I set
up external process catching the requests and sending appropiate PUTs?

(I could set up proxies or intermediate webapp instead, but I want to
avoid extra infrastructure and like an idea of making stuff able to
couch-replicate as much as possible; that's why external process seems
heavyweight as it requires preconfiguration instead of just
replication.)

cheers,
Wojtek

Re: workaround for cross-site PUTs

Posted by Chris Anderson <jc...@apache.org>.
On Tue, Jun 9, 2009 at 10:17 AM, Wojciech
Kaczmarek<ka...@gmail.com> wrote:
> Hi!
>
> I'm going to hack a Greasemonkey script which would automatically
> update CouchDB docs from a webpage content. It needs to be done at the
> browser side, server side is out of reach for modification.
>
> I can't use XMLHttpRequest as it doesn't allow cross-site requests.
> When using jQuery's ajax with jsonp (or whatever application of script
> tag injection) the requests are limited to GETs. So I'm going to have
> a layer in the CouchDB translating external GETs to document-writing
> PUTs.
>

You may be able to do POST using a hidden form in an iframe. This
would be posted as form encoded key value pairs, but CouchDB should be
able to handle those for creating a document - if it can't we should
make it handle those.

Otherwise you can wait for the _update mechanism to be ready, which
should be able to create a document in response to a get request.
(Still a bad idea but not super bad if it's triggered from
greasemonkey.)

> Is couchapp able to do this with some of its helpers or should I set
> up external process catching the requests and sending appropiate PUTs?
>
> (I could set up proxies or intermediate webapp instead, but I want to
> avoid extra infrastructure and like an idea of making stuff able to
> couch-replicate as much as possible; that's why external process seems
> heavyweight as it requires preconfiguration instead of just
> replication.)
>
> cheers,
> Wojtek
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io