Hexo-theme-next: AlgoliaSearchError: Please provide an API key. Update index fails

Created on 10 Jun 2017  ·  2Comments  ·  Source: iissnan/hexo-theme-next

Expected behavior (预期行为)

当配置完成,在站点根目录下执行 hexo algolia 来更新 Index 并成功

Actual behavior (实际行为)

AlgoliaSearchError: Please provide an API key. Usage: algoliasearch(applicationID, apiKey, opts)

Steps to reproduce the behavior (重现步骤)

I am stricly following the tutorial guide of this link
http://theme-next.iissnan.com/third-party-services.html#search-system

NexT Information

Add the ✔ sign before an item which is affected by this behavior.

NexT Version:

  • Master ✔
  • Latest Release
  • Old version -

NexT Scheme:

  • All schemes
  • Muse
  • Mist
  • Pisces ✔

Other Information (Like Browser, System, Screenshots)

image

  • 我确定我按照要求修改了站点配置文件,applicationID 可以顺利找到,然而提示找不到API Key,这是为什么呢?
algolia: 
  applicationID: KEBR84**** 
  apiKey: 04efacb********75bda019f
  adminApiKey: fb5e363******d32a7e35 
  indexName: **** 
  chunkSize: 5000 

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next


Most helpful comment

自己来回答一下,最开始以为是自己使用了data file的方式导致了问题,换了主题,全部从头开始还是有这个问题。 答案应该在hexo-algolia的更新上。用了最新版本的hexo-algolia 1.1.0, 这个版本是3天前提交的,通过callstack查到了lib下的command.js

module.exports = function(args, callback) {
  var hexo = this;
  var config = hexo.config;
  var HEXO_ALGOLIA_INDEXING_KEY = process.env.HEXO_ALGOLIA_INDEXING_KEY;

  var client = algoliasearch(
    config.algolia.applicationID,
    HEXO_ALGOLIA_INDEXING_KEY
  );

从hexo.config里并没有去取apiKey和adminKey呀。 apiKey 是一个searchOnly的key,对于content 的indexing 我们是用不到的。作者要求采用环境变量的方式来设定indexingKey,这是从安全的角度来考虑的。
参考最新的说明
https://github.com/oncletom/hexo-algolia/tree/20f6ecfde2b3348c2fba5ffc3963cc1ba7d2e3cb
我直接用adminKey来作为indexingKey是不行的,通过新建的Key加上对应的scope就可以了。

All 2 comments

自己来回答一下,最开始以为是自己使用了data file的方式导致了问题,换了主题,全部从头开始还是有这个问题。 答案应该在hexo-algolia的更新上。用了最新版本的hexo-algolia 1.1.0, 这个版本是3天前提交的,通过callstack查到了lib下的command.js

module.exports = function(args, callback) {
  var hexo = this;
  var config = hexo.config;
  var HEXO_ALGOLIA_INDEXING_KEY = process.env.HEXO_ALGOLIA_INDEXING_KEY;

  var client = algoliasearch(
    config.algolia.applicationID,
    HEXO_ALGOLIA_INDEXING_KEY
  );

从hexo.config里并没有去取apiKey和adminKey呀。 apiKey 是一个searchOnly的key,对于content 的indexing 我们是用不到的。作者要求采用环境变量的方式来设定indexingKey,这是从安全的角度来考虑的。
参考最新的说明
https://github.com/oncletom/hexo-algolia/tree/20f6ecfde2b3348c2fba5ffc3963cc1ba7d2e3cb
我直接用adminKey来作为indexingKey是不行的,通过新建的Key加上对应的scope就可以了。

简单来说,就是在ALL API KEYS 中新建一个key ,在本地利用export HEXO_ALGOLIA_INDEXING_KEY=…将新建的key绑定到HEXO_ALGOLIA_INDEXING_KEY就可以了.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwwangchn picture jwwangchn  ·  3Comments

keltoy picture keltoy  ·  3Comments

chy9002 picture chy9002  ·  3Comments

syscca picture syscca  ·  4Comments

Nirvanada picture Nirvanada  ·  4Comments