I found the answer here to the question below.
I needed to configure a reverse proxy in apache, which took about 2 minutes, adding the following line to my virual host;
ProxyPass / couchdb / http: // dojo: 5984 /
Due to the same origin policy, you cannot send data through ports. I knew that this applies to domains, but not to other ports, so you are setting up a reverse proxy.
I would like to know how I can send POST data to couchDB using JavaScript or jQuery.
I followed this tut and created a database, and I can send and receive data using curl, and it all works fine. The following are examples of twisting that I used.
I can also get data using jQuery, but I don't know how to use POST for CouchDB
curl -X GET http://127.0.0.1:5984/mycouchshop/_all_docs .
curl -X POST http://127.0.0.1:5984/mycouchshop/ -d @ person.json -H "Content-Type: application / json"
I can receive and display data using jQuery. The code below works fine.
$.ajax({ url : 'http://couchdb:5984/mycouchshop/_design/peoples/_view/people', type : 'GET', dataType : "jsonp", success : function(json) {} });
But publishing the data leads to an invalid 405 method
$.ajax({ url : 'http://couchdb:5984/mycouchshop/', data : {"forename": "Bob", "surname": "McHamster", "type": "person"}, contentType : "application/json", type : 'POST', dataType : "json", success : function(resp) {} });
source share