Thanks for contacting Algolia!
From your question: “How do I enrich the response coming from Algolia with a custom message/error, e.g.: an user without entitlements should see a paywall rather than the results?”
I understood this to mean that in Algolia you have an index of data (your results), some users have roles/permissions to see these results, and others do not.
I would consider Algolia as the home of your results data, however, these paywalls or error-messaging can be handled on the frontend. That is:
- search Algolia
- before/after your middleware determines authorisation level of user
- if user has sufficient authorisation, show hits/filters and other InstantSearch widgets on frontend
- if user has insufficient authorisation, hide hits/filters and other InstantSearch widgets on frontend; display your message
My own instinct would be to handle this custom error messaging client side, using CSS to hide the elements conditionally based on authorisation. I hope this helps!