xlanex6 / nuxt-meilisearch

🔎 Meilisearch module for Nuxt 3
https://nuxt-meilisearch.vercel.app
MIT License
118 stars 16 forks source link

The provided API key is invalid when using $meilisearch #131

Open Rednas83 opened 2 months ago

Rednas83 commented 2 months ago

This is strange because useMeiliSearch("movies") is working without errors.

Is perhaps an adminApiKey required or is there something else wrong with $meilisearch

server/api/search/add/[document].ts

export default defineEventHandler(async (event) => {
  const addRecordRes = await $meilisearch.index("movies").addDocuments([
    {
      id: 999999994234,
      title: "Batman Unmasked: The Psychology of the Dark Knight",
      poster: "https://image.tmdb.org/t/p/w1280/jjHu128XLARc2k4cJrblAvZe0HE.jpg",
      overview: "Delve into the world of Batman and the vigilante justice tha",
      release_date: "2008-07-15",
    },
  ])

  return { myCustomResponse: "Document is on the way....", addRecordRes }
})
Rednas83 commented 2 months ago

Fixed it by copying the searchApiKey to the adminApiKey.

Looks like the local server only uses a single master key for adding and searching image

Perhaps make the adminApiKey default for users that run mellisearch locally?

xlanex6 commented 2 months ago

Hi @Rednas83

Why not? Can you suggest a PR?

Keep in mind that search and admin keys give more flexibility on roles and permissions.