Hi, I'm trying to deploy a webpage that uses Types...
# community-help
e
Hi, I'm trying to deploy a webpage that uses Typesense-instantsearch-adapter to CloudFlare pages (using CF workers to server side render), and while it can fetch results from within the browser, I can't server side render the page since Typesense-js relies on axios which uses node APIs which aren't available in a serverless context. This is essentially the same problem that this thread discusses: https://typesense-community.slack.com/archives/C01UZEXF5FY/p1643168574904559 My problem is that I can't use the typesense-deno fork mentioned in that thread since Typesense-instantsearch-adapter doesn't allow me to pass in a custom searchClient implementation. Now I could use typesense-deno and fork the adapter to use that library instead, but before I do that I was wondering if moving away from axios towards something like cross-fetch is a possibility?
j
My understanding is that axios works both in node.js and browser envs...
Sounds like there's something specific about the Cloudflare pages env that's preventing axios from working?
In any case, I know some users rely on the ability to customize axios with additional interceptors, etc. So it would be a major backward incompatible change for us to switch http clients
My problem is that I can't use the typesense-deno fork mentioned in that thread since Typesense-instantsearch-adapter doesn't allow me to pass in a custom searchClient implementation.
Interesting. You mean the typesense-js library right? This should be doable by changing this line to accept a typesenseClient from
options
if it is specified. I'd be open to a PR to do that
e
Yup, axios works in node.js and browser envs, just not in the serverless env of CloudFlare workers and other serverless platforms. I think they have access to the same serviceWorker environment that PWAs use. I'll open a PR to be able to override the client, the only problem is that I'd have to maintain an axios-less fork of typesense-js. But according to this it seems like axios is planning to add a fetch-based adapter anyway, so I'll just do it this way for now until they release that. I think I'll be able to get the PR out on Friday 🙂
👍 1