(Taking this back onto the mailing list.)

From a pure javascript perspective, yours is clearly the correct answer. However, it leads to a difficulty that seems to be inherent in couch.js. Basically, I tried to set the database name using (in pseudo-code)

if (window.location matches /proxyserver...\/couch\//)
    set dbname to couch/myapp
else
    set dbname to myapp

I then called the CouchDB function (inside couch.js) with the resulting dbname. However, CouchDB assumes that the database name is a single component and passes it through encodeURIComponent. Thus, when my script correctly detects that it is coming from the proxy server, the dbname get rewritten as
    couch%2Fmyapp
which again leads to a 404 Not Found error.

I suppose I could try forcing an overwrite of the uri element stored in Couch DB; does anyone have a better suggestion?

Thanks,
    Kevin

On 10/27/2010 6:05 PM, Keith Gable wrote:
On Wed, 2010-10-27 at 17:45 -0500, Kevin R. Coombes wrote:

Does anyone have an example that illustrates (using javascript and
couch.js) how to figure out which machine originated the call?

      Kevin
I haven't used couch.js, but I assume it runs in the context of the
browser. So just use window.location and match it against a regex. If it
matches the one that looks like /^http:\/\/site.com\/couch\// then it's
external otherwise internal.

Reply via email to