-
Notifications
You must be signed in to change notification settings - Fork 98
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Below is a workaround
class FixedMeilisearchClient(meilisearch.Client):
"""
Fixed Meilisearch client that properly propagates custom_headers to Index instances.
This fixes a bug in the official client where custom_headers provided to the Client
are not passed to Index instances, causing authentication failures.
"""
def __init__(
self, url, api_key=None, timeout=None, client_agents=None, custom_headers=None
):
"""
Initialize the fixed Meilisearch client.
Args:
url: Meilisearch server URL
api_key: API key for authentication (can be empty when using custom_headers)
timeout: Request timeout in seconds
client_agents: Additional client agent information
custom_headers: Custom headers (e.g., for bearer token authentication)
"""
super().__init__(url, api_key, timeout, client_agents, custom_headers)
self._custom_headers = custom_headers
def index(self, uid):
"""
Get an index with properly configured custom headers.
Args:
uid: Index UID
Returns:
Index instance with fixed HTTP client
"""
index = super().index(uid)
# Fix the index's http instance to include custom headers
if self._custom_headers:
index.http = HttpRequests(index.config, self._custom_headers)
return indexMetadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers