Instantsearchjs - Method not allowed with this API key

Trying to build a client-side js interface per this tutorial: https://www.algolia.com/doc/tutorials/search-ui/instant-search/build-an-instant-search-results-page/instantsearchjs/

Here is my draft page: https://obeyclothingau.myshopify.com/pages/wb-search

Getting this error AlgoliaSearchError: Method not allowed with this API key↵ at u (https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js:3:1694)

I’ve updated the API key permissions to include Search, Browse Index, List Indices, Get Index Settings

Anyone have same issue?

Hey @wm.belk :wave:

It seems that you’re trying to use setSettings directly from your front-end using you Search-only API key:

index.setSettings({
  searchableAttributes: [
    'tags'
  ],
  customRanking: ['desc(popularity)'],
});

You should do this using any back-end implementation (e.g. Node.JS, Ruby, PHP, etc.).

Let me know if you need further help on this!

Thanks @gianluca.bargelli, can this be done once from a local server to save the settings? After that, could I just use all client-side calls? Basically I find your Shopify implementation to be incredibly overly complex and does not play nice with my git repo one bit, because it overwrites files directly on the Shopify server. I manage a big handful of shops and I want them all to use the same client code across the board. If I can simply make calls using API key on the client, it would simplify my life 100x.

I tried the following from a node file but receiving this error:

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): AlgoliaSearchError: Method not allowed with this API key


var client = algoliasearch('#', '#');
var index = client.initIndex('index_name');

index.setSettings({
  searchableAttributes: [
    'body_html',
    'options',
    'tags',
    'title',
    'variant_title'
  ],
  customRanking: ['desc(popularity)'],
});