-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double Search Requests & Insights Middleware Error #6599
Comments
Any suggestions for insights? looks like it can't be done using the provider |
The short version is that you’re adding Concretely, in stateToRoute: if (typeof window !== "undefined") { …you add objectID to the route state that’s returned. But in routeToState: routeToState(routeState = {} as UiState) { …you never read that objectID key nor put it back into the returned UiState. Fix would be either removing that objectID logic or handling it more consistently: make routeToState store that key in uiState the same way it’s set in stateToRoute. That consistency will keep the route state stable and avoid the unwanted query. I haven't had the time to dive into insights for now but it seems like there was no initialisation of our insights library. |
Thanks for responding @mathougui , tried to removed entirely the stateMapping and routing part, its still triggers two consecutive api calls https://codesandbox.io/p/github/daryldeogracias/algolia-web-app/main |
this seems to happen only when we do backend search |
🐛 Current behavior
When performing a search request, each keypress triggers two consecutive API calls to
/api/search
(backend search setup) . Additionally, enablinginsights={true}
causes an insights error.🔍 Steps to reproduce
http://localhost:3000/api/search
to the correct URL (e.g.,https://xyz-3000.app.codesandbox.io/api/search
)./api/search
.insights={true}
in InstantSearchNext.Live reproduction
https://codesandbox.io/p/github/daryldeogracias/algolia-web-app/main
💭 Expected behavior
Package version
"next": "^15.1.6", "react-instantsearch": "^7.15.3", "react-instantsearch-nextjs": "^0.4.4", "algoliasearch": "^5.20.0", "instantsearch.js": "^4.77.3",
Operating system
macOS 15.3.1 (24D70)
Browser
Chrome Version 133.0.6943.142
Code of Conduct
The text was updated successfully, but these errors were encountered: