Search code examples
couchdbhostingsproutcorepaascloudant

Best place to host my Sproutcore app backed up by Cloudant CouchDB?


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).


Solution

  • 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.