Netlify edge build SSR request fails
Version
@nuxtjs/algolia: 1.10.2 nuxt: 3.11.2
Reproduction Link
Don;t have time to reproduce on netlify and have fixed the issue since then
Steps to reproduce
Use one of the composables useAlgoliaSearch to perform a search, locally works fine. On netlify SSR fails but client side works.
What is Expected?
SSR Works
What is actually happening?
Not sure what is going on internally with the requests but putting the useFetch config option to true fixes the issue.
Wasn't sure if this is a bug in the module or underlying algolia library but it took me a while to figure out so thought I would put it here.
Hey Buddy,
Thanks for reporting this issue.
However, I am not sure if I will be able to help. Could you provide more details like reproduction link or at least the error your got?
Then, I will be happy to help :)
I think i'm running into the same issue with Cloudflare workers. useAlgoliaSearch() works fine client side, but not on the server.
Have an app deployed with nuxt hub, which currently doesnt have the best debug experience, so i cant access any errors from server logs.
I thought it migth have something to do with the requester. I know that @algolia/requester-node-http is not available in edge runtimes, but setting runtimeConfig.public.algolia.useFetch = true did not solve the issue
nuxtApp.$algolia.transporter.requester = (await import('@algolia/requester-node-http').then(lib => lib.default || lib)).createNodeHttpRequester()
I'll try to do some more digging into the cause next week
PS. I know algoliasearch v5 has some improvements regarding edge runtimes, upgrading to the latest major version of the client might resolve the issue. I have another project running on CF which uses the algolia client (v5) directly, and the search method works out of the box
Hey there, for the server side usage, I recommend using useAsyncAlgoliaSearch composable that does exactly what you did under the hood :)
Yes, but that one still doesn't work... I think I'm going to switch to the latest algolia client itself, since I'm not really using anything other then searchIndex() and multipleQueries().