Error: AlgoliaSearchError: Method not allowed with this API key

I am getting this error while running gatsby build

success Building static HTML for pages - 0.537s - 170/170 316.73/s
[Algolia] 1 queries to index
[Algolia] Running 1 query for index my-index-name...
[Algolia] Query resulted in a total of 122 results
⠋ onPostBuild


  AlgoliaSearchError: Method not allowed with this API key

I am using the gatsby-plugin-algolia and have setup my gatsby-config.js file as follows:

require('dotenv').config({
  path: `.env.production`
});

const BlogQuery = `
  {
    allMarkdownRemark {
      nodes {
        id
        excerpt
        frontmatter {
          description
          tags
          title
        }
        internal {
          content
        }
      }
    }
  }
`

const queries = [
  {
    query: BlogQuery,
    transformer: ({ data }) => data.allMarkdownRemark.nodes,
    matchFields: ['slug', 'modified'],
  }
];

<---The rest of my config that does not affect this plugin--->

{
      resolve: `gatsby-plugin-algolia`,
      options: {
        appId: process.env.ALGOLIA_APP_ID,
        apiKey: process.env.ALGOLIA_SEARCH_KEY,
        indexName: process.env.ALGOLIA_INDEX_NAME,
        queries,
        chunkSize: 1000,
      },
      enablePartialUpdates: true,
      matchFields: ['slug', 'modified'],
    },

In my .env.production file I have the following:

ALGOLIA_APP_ID=using Application ID
ALGOLIA_SEARCH_KEY=using the Search-Only API Key
ALGOLIA_ADMIN_KEY=using the Admin API Key
ALGOLIA_INDEX_NAME=using the name of my Index found in Algolia -> Indices 

All the above .env values are gathered from my admin portal:

Any guidance or suggestions on resolving this error would be appreciated. Thank you.

Not sure if this is relevant but I am getting 403 errors on Get.

Found at Algolia → Indices → Search API Logs at:

1/indexes/my-index-name/settings?getVersion=2

Hi @isaac2 Could you try setting your keys like this:

// .env.production
ALGOLIA_APP_ID=XXX
ALGOLIA_API_KEY=XXX
ALGOLIA_INDEX_NAME=XXX

The ALGOLIA_API_KEY should be the Algolia Admin API key

1 Like

That did the trick @cindy.cullen I did need to also update the variable in the gatsby.config.js file as well, but once the name was changed in those two files (and the Netlify Environment too) everything started working. Thank you very much!

If anyone is interested I blogged about my Gatsby/Netlify/Algolia install experience…

2 Likes

Thank You Cindy! this is the solution.

1 Like