Problem (Same Origin Policy) using Vue.js and Couchdb

Asked

Viewed 22 times

0

I’m making a post request through the Vue.js, to create a document in the Couchdb, I enabled Cors in couchdb with *, left the database enabled for the user admin and made the following code:

  var csrfmiddlewaretoken = document.getElementsByName('csrfmiddlewaretoken')[0].value;
  var cred_ = btoa('admin:admin')

  var form:{
    nome:"Fulano"
  }
  this.$http.post('http://127.0.0.1:5984/formulario/data
    form,
    {headers:{
      "X-CSRFToken":csrfmiddlewaretoken,
      "Authorization":"Basic "+cred_,
    }
  }).then(function(response) {
    console.log(response)
  }, function(response) {
    console.log(response)
  });

The following error is shown:

Same Origin Policy (Same Origin Policy) prevents reading the remote resource in...

1 answer

0

Solved by reading the documentation of couchdb, was applying the wrong method, was thus the right code.

varcred_ = btoa('admin:admin')

var form:{ name:"So-and-so" } this. $http.put('http://127.0.0.1:5984/form/date form, {headers:{ "Authorization":"Basic "+cred_, } }). then(Function(Sponse) { console.log(Sponse) }, Function(Sponse) { console.log(Sponse) });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.