【问题标题】:ionic+firebase+elasticsearch can't auth with elasticsearch.jsionic+firebase+elasticsearch 无法使用 elasticsearch.js 进行身份验证
【发布时间】:2019-02-14 18:00:49
【问题描述】:
const client = new elasticsearch.Client({
  host: [
    {
      host: '35.192.45.130//elasticsearch',
      auth: 'user:password',
      protocol: 'http',
      port: 80
    }
  ]
});
//

await client.ping({
  // ping usually has a 3000ms timeout
  requestTimeout: 1000
}, function (error) {
  if (error) {
    console.trace('elasticsearch cluster is down!');
  } else {
    console.log('All is well');
  }
});

我无法授权使用 ionic 进行弹性搜索。但是使用 Postman,我已经可以登录并执行一些操作了。

错误是

对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,Origin 'http://localhost:8100' 不允许访问。响应的 HTTP 状态代码为 401。

【问题讨论】:

标签: node.js typescript firebase elasticsearch ionic-framework


【解决方案1】:

解决方案是在 chrome 浏览器中使用 this plugin 在浏览器中启用 CORS

更多关于 CORS here

【讨论】:

    猜你喜欢
    • 2016-04-08
    • 2015-06-29
    • 2019-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-30
    • 2020-10-09
    • 2017-03-11
    相关资源
    最近更新 更多