nuxt-modules / algolia

🔎 Algolia module for Nuxt
https://algolia.nuxtjs.org/
MIT License
191 stars 35 forks source link

Add parameter to use a secured API key instead of the global api key in the config #207

Open Splinteer opened 1 month ago

Splinteer commented 1 month ago

Is your feature request related to a problem? Please describe.

I have user restricted data in my indexes but the only way to access it is using a secured API key. But actually the searchClient is created via useAlgoliaRef() that use the global search key.

Describe the solution you'd like

I need a way to pass the apiKey to the useAlgoliaRef() composable

Baroshem commented 1 month ago

Hey there,

What about passing index as a parameter for useAlgoliaSearch composable? https://algolia.nuxtjs.org/getting-started/usage#usealgoliasearch

The one passed in the composable should be applied before the global one

Splinteer commented 1 month ago

Because the index doesn't change, and if you want user restricted data you must use a different api key. Cf: https://www.algolia.com/doc/guides/security/api-keys/how-to/user-restricted-access-to-data

Baroshem commented 1 month ago

Ahh I see, makes sense.

Would you be interested in contributing to the module with this change? I can provide the help if needed :)