setSettings method is not working

Hi,

I am implementing algolia search using javascript api and but setSettings method is not working. I always getting the response - “{“message”:“This method is only available in HTTPS”,“status”:403}”. Actually I wanted to implement dynamic sorting using different sorting technique (ex. price, newest, oldest etc.). I also set custom ranking attributes from admin. My code is given below, please sugges me what to do, it’s urgent.

index.setSettings({
customRanking: [
‘desc(price)’,
]
});

Hey there,

By default the Algolia Javascript client will use http if the current protocol is http, https otherwise.
My guess is that you are trying to call setSettings from the frontend which is not secured given you would need to publicly expose your admin api key.

setSettings and all other “write” operations should be done in the backend of your application.

Let me know if my answer doesn’t make sense in your use case, I’d happily dig a bit further.

To solve this you can:

var client = algoliasearch(appId, apiKey, {protocol: 'https:'});

This should solve it.

Thanks for your reply,
I already used it before, but getting following response.

{“message”:“Method not allowed with this API key”,“status”:403}

Thanks for your reply,

So please tell my how can i manage dynamic sorting attribute (ex. price, popularity) from client side.