New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Invalid Host" error when running in the browser #729
Comments
I'm having a similar problem. From reading AWS docs https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-handling-errors.html#aes-troubleshooting-host-header a host header should be sent, but elasticsearch-js isn't transparent about whether it sets a host header, or what mechanism there is to set one. The code has references to |
More digging - there is a host class that can be used when setting up a client. This allows explicit setting of headers: https://github.com/elastic/elasticsearch-js/blob/9c98262b871f860afccc04f8025c35c45aea2281/docs/host.asciidoc Please can maintainers make this easier to find. No links at all from the readme |
I had the same problem. In my Angular client I was also using elasticsearch-browser and http-aws-es. I was able to get it working by removing elasticsearch-browser and using elasticsearch. Those 2 libraries are conflicting because your Host class in one is not the same as the Host class in the other. |
We understand that this might be important for you, but this issue has been automatically marked as stale because it has not had recent activity either from our end or yours. Note: in the past months we have built a new client, that has just landed in master. If you want to open an issue or a pr for the legacy client, you should do that in https://github.com/elastic/elasticsearch-js-legacy |
I'm trying to get elasticsearch-js working in a browser application using the http-aws-es 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')
Did anyone get a similar setup working in the browser and what am I doing wrong? I did some debugging and it seems that the check in ConnectionAbstract is failing:
`
function ConnectionAbstract(host, config) {
config = config || {};
EventEmitter.call(this);
this.log = config.log || new Log();
this.pingTimeout = config.pingTimeout || 3000;
if (!host) {
throw new TypeError('Missing host');
} else if (host instanceof Host) {
this.host = host;
} else {
throw new TypeError('Invalid host');
}
utils.makeBoundMethods(this);
}
`
The text was updated successfully, but these errors were encountered: