CouchApp without Server side or CouchDB backend with xdomain issues?

后端 未结 2 950
余生分开走
余生分开走 2021-02-03 14:44

I have been playing with CouchDB and CouchApp for a little while now. I am planning on using it for a new web site project I\'m working on.

  1. From a scalability vi

2条回答
  •  盖世英雄少女心
    2021-02-03 15:43

    Excellent answer from BigBlueHat, but I have one more more possible option to add:

    Overcome the cross-domain problem, thereby allowing you to serve pages from any sort of web server, and also allowing the browser to interact directly with CouchDB ( which can be on another server ).

    The cross-domain restriction, as enforced by browsers, is not that hard to get around. The 2 main methods that I know of are: JSONP and CORS.

    JSONP disguises each request as "script" request ( as script requests are exempt from the cross-domain rule). It only works for GET, not POST or PUT or anything else. You can do it with jQuery.

    CORS is "Cross Origin Resource Sharing", and it is simply a special HTTP Header that must be implemented on the server ( couchdb in this case ), which tells the browser that it's OK -- it doesn't mind serving requests that come from another domain. I have tested this, and it does work, but there might be security issues -- I am not sure.

    So...I don't know whether it's a good idea, but it is technically possible to ( at least partially ) overcome the cross-domain restriction with CouchDB. Has anyone ever built a system using this type of setup?

提交回复
热议问题