elastic / search-ui

Search UI. Libraries for the fast development of modern, engaging search experiences.
https://docs.elastic.co/search-ui
Apache License 2.0
1.92k stars 368 forks source link

Cookie don't send using ElasticsearchAPIConnector #1064

Closed T-iny closed 1 month ago

T-iny commented 4 months ago

Describe the bug The cookie in the network request is missing. The host is a REST API wrapper. To Reproduce

  1. Setup
    • Connector: const connector = new ElasticsearchAPIConnector( { host: process.env.NEXT_PUBLIC_ELASTIC_CONNECTOR_HOST, index, connectionOptions: { headers: { Authorization: Bearer ${authState?.accessToken?.accessToken}, }, }, }, } );

SearchProvider: - <SearchProvider config={{ ...config, apiConnector: new ElasticsearchAPIConnector({ host: process.env.NEXT_PUBLIC_ELASTIC_CONNECTOR_HOST, index, }), }} driver={driver}

Expected behavior The cookie send with request. Screenshots If applicable, add screenshots to help explain your problem.

Which backends and packages are you using: Backend: [custom] Packages: [ElasticsearchAPIConnector]

Please review. Thanks!

saarikabhasi commented 3 months ago

Hi, The ElasticsearchAPIConnector constructs elasticsearch query and the requests do not use cookies by default. If you would like to use cookies, it should be handled in your application.

T-iny commented 3 months ago

Thanks for your answer @saarikabhasi . The connector manage the request itself. I have set a Bearer Token in the header in the ElasticsearchAPIConnector. But I can not catch the 401 error, Is there any way to catch the 401 error and refresh token? Or is there any way to get the http response? The code I used is like this.

({ ...props })} key={userInfo} > {(searchContextState: SearchContextState) => { const results = removeRaw(searchContextState.results); const { searchTerm, current, resultsPerPage, removeFilter, filters, setSearchTerm, clearFilters, isLoading, totalResults, } = searchContextState;
saarikabhasi commented 3 months ago

You could try catching errors in your server side code. We currently have example in our doc on how to integrate with node.js.

botelastic[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Is this issue still important to you? If so, please leave a comment and let us know. As always, thank you for your contributions.