[Vuejs]-Tried to connect to elasticsearch with axios

0👍

I assume, your browser doesn’t respect the credentials passed via the url. You can pass the authentication information directly inside your config object (where you also define the params) by setting the auth property as listed in the axios docs.

auth: {
  username: 'username',
  password: 'password'
}

Please notice that you possibly need the withCredentials parameter to be set to true depending on the configuration of the backend you are targeting.

As this code looks like you are accessing the elasticsearch instance directly from the browser, you should be aware that your database then is exposed to all clients and the authentication information can also be read from your client-side javascript. That’s probably not what you want.

Leave a comment