I have a Sproutcore application which uses CouchDB hosted by Cloudant. In devenv I'm using Sproutcore proxy to forward requests to Cloudant (due to single origin policy I obviously can't call a arbitrary hosts from my JavaScript).

What would be your suggestion on hosting the app. CouchApps loading script is failing with obscure error (please note Sproutcore app is around 40 MB of JavaScript and resources).

Accepted Answer

The thing about hosting an app that talks directly to couchdb is that you are restricted by the same origin policy, so the server that serves up your SproutCore app, has to be on the same domain as you access your couchDB database. If your host provides a static file server, you could use that, but your best bet is probably just to save it as a couch app.

The Key with deploying SC as a couch app, is that you have to set up the URL's that sc-build generates to point to the correct location. This can be done with the buildfile setting something like this:

:url_prefix => '<database>/_design/<designDocument>/'

This way the links point to the right location.

You can also setup CouchDB url rewrites to get simpler urls if you wish. Have a look here for more discussion on this:

https://groups.google.com/d/topic/sproutcore/-D-5T5yPg3A/discussion

PS: 40mb seems overly large! do you have many images? I'd be concerned if you had that much JS/CSS.

Written by geoffreyd
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki