Algolia with Cordova

We create a webapp in Angular using algolia api for searching. Now we want to make the hybrid version of the app using cordova. The app works well beside of the algolia request that respond with 403. We used the algolia angular client. We notice that if we deactivate the referer filters the api responds normally. Is it possible to use that filter and make the app works as well? Do you have some suggestion about how to let algolia works with cordova?

Hi @winkle,

I’m not sure to fully understand your issue here. Does the Algolia request that respond with 403 has an error message that you can share?

Hi,
the problem is that phonegap/cordova will send the request to algolia with, in the headers, origin: file://.
Algolia answers with “request not allowed by the referer”

1 Like

@winkle I’m not sure I fully understand your issue as well, but it sounds like there are some request headers set that are not allowed. Can you maybe provide a screenshot or link to implementation so we can investigate? Thanks :slight_smile:

This is the request headers sents by our app using cordova:

Have you ever had expirience with cordova apps?

1 Like

I just got an answer from our infrastructure team and they confirmed that the Origin: file:// header is not causing the 403 permission error and it is more likely that your credentials are incorrect. Can you please verify that you are supplying the right credentials?
Thanks!

Hi, thank you for your answer. I check it and it works only if I doesn’t define any referer filter. There is someway to add some referer filters and also to allow file:// ? In other words we want to limit the access to specific domain if they use normal origin but allow also origin file://

Could you share what referer filter you have set up for the API key you use, maybe adding file:// to it, or making another one for the Cordova app?