Skip to content

how to use sendApiKeyAsQueryParam with instantsearch react? #187

@weiklr

Description

@weiklr

Description

Even though i set sendApiKeyAsQueryParam to false when i create a new TypesenseInstantSearchAdapterOptions react-instantsearch still sends queries with X-TYPESENSE-API-KEY http header.

How do i override react-instantsearch and make it post the api key under the payload body instead? I have a very long api key (> 2000 characters), and it's not going through some api gate ways as their request header limit is small.

Steps to reproduce

const generateTypesenseInstantsearchAdapterOptions = (): TypesenseInstantsearchAdapterOptions => {
  // Search settings for full search
  return {
    server: {
      apiKey: '',
      nodes: [
        {
          host: ApiSettings.HOST,
          port: ApiSettings.PORT,
          protocol: ApiSettings.PROTOCOL,
        },
      ],
      sendApiKeyAsQueryParam: false,
    },
  };
};

const typesenseInstantSearchAdapter = new TypesenseInstantsearchAdapter(typesenseOptions);
const searchClient = typesenseInstantSearchAdapter.searchClient;

      <InstantSearch
        searchClient={searchClient}
        indexName={INDEX_NAME}
        onStateChange={onStateChange}
        initialUiState={getInitialUiState()}
      >
     </InstantSearch>

Expected Behavior

I expect react-instant search not to send X-TYPESENSE-API-KEY when a query is sent

Actual Behavior

react-instant search still sends api key with the header
Typesense Version: 0.23.1

OS: Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions