Skip to content

"Invalid Host" error when running in the browser #59

@MichaelAnckaert

Description

@MichaelAnckaert

I'm trying to get http-aws-es working in a browser application using the elasticsearch-js library. My code is currently looking like this but I'm getting a "TypeError: invalid host" in the browser console.

`
let AWS = require('aws-sdk')

  let options = {
    hosts: ['https://my-es-host.es.amazonaws.com'],
    connectionClass: require('http-aws-es'),
    awsConfig: new AWS.Config({
      credentials: new AWS.Credentials('AKA...', 'secret'),
      region: 'eu-central-1'
    }),
    httpOptions: {}
  }

  let es = require('elasticsearch-browser').Client(options)

  es.ping({
    requestTimeout: 30000
  }, function (error) {
    if (error) {
      console.error('elasticsearch cluster is down!')
    } else {
      console.log('All is well')
    }
  })`

Did anyone get a similar setup working in the browser and what am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions