nuxt-modules / algolia

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

feat: added fetch requester for ssr reasons #194

Closed Rigo-m closed 3 months ago

Rigo-m commented 3 months ago

Fixes https://github.com/atoms-studio/nuxt-swiftsearch/issues/1

Types of changes

Description

useAlgoliaRef exports the esm/browser version of the algoliasearch client. The browser version uses the browserXHRRequester, which doesn't work in node environments, while the non-esm package works both in client and in server environments because it automatically switches XMLHttpRequester and browserXHRRequester depending on the environment it's called within, and that's why algoliaclient works but useAlgoliaRef does not when passing it to swiftsearch.

Proposed fix is to ubiquitously use the fetch requester, which is a better "futuristic" (more contemporary) approach.

If this works for you I'm going to implement swiftsearch integration after.

Baroshem commented 3 months ago

Hey @Rigo-m

Thanks for this PR! I will review it shortly and release it at the end of the week as I am currently off for short holidays