#community-help

Resolving CORS Issue with Typesense Cloud and Axios

TLDR Edward faced a CORS issue with Typesense Cloud and axios. After requesting help to diagnose the problem, they resolved it by configuring an individual axios instance rather than the whole axios package, mitigating a potential axios conflict. They will be adding notes to the Typesense instant search package documentation.

Powered by Struct AI
Apr 27, 2022 (20 months ago)
Edward
Photo of md5-abd5ee17039f6a27ff7f2bc0e3ef7131
Edward
11:43 AM
We've been experiencing a CORS issue when making a request to our cluster.
We also use axios for our system and have default overrides set which we think are conflicting with the typesense axios setup. Is there a chance that our setting for 'withCredentials' = 'include' is causing this?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:03 PM
Are you using Typesense Cloud or self hosting? Can you please post the exact error?
Edward
Photo of md5-abd5ee17039f6a27ff7f2bc0e3ef7131
Edward
12:05 PM
Typesense cloud

I haven't got the whole error as we've moved on from here but I'll see if I can recreate it
12:14
Edward
12:14 PM
I feel this is also affecting our ability to see hits.

We are overriding the default axios behaviour for responses

axios.interceptors.response.use((response) => {
  return response.data
})

Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:20 PM
I'm not familiar with axios but if you can provide a standalone example that show cases the issue that I can run, then I can see what's going wrong.
Edward
Photo of md5-abd5ee17039f6a27ff7f2bc0e3ef7131
Edward
12:24 PM
I should have been clear that we are using the typesense-instantsearch-adapter which appears to use axios for fetching
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:25 PM
Can you post a screenshot of the error or a screencast of the issue?
Edward
Photo of md5-abd5ee17039f6a27ff7f2bc0e3ef7131
Edward
12:28 PM
Sorry, it looks like we've resolved it now. We created a separate instance of axios in our original system and therefore were only configuring the instance, not the entire axios package This seems to have fixed our issue. I'll write a readme addition for the typesense instant search package so that it's clear about the potential axios conflict.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:28 PM
That would be great 👍

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community