Hi there, I am using `typesense-instantsearch-adap...
# community-help
p
Hi there, I am using
typesense-instantsearch-adapter
with
react-instantsearch-nextjs
and enabled
routing
option there. Everything works fine. But if I manually add any negative number there, it throws this error
Error: 400 - Parameter page must be an unsigned integer
with Internal server error on my site. So my ques is, how can I validate
page
and/or other params before adapter makes a request?
f
Hey there, could we provide a simple reproducible example so I can test it out myself?
p
https://recipe-search.typesense.org/ 1. Open this official example with browser console open 2. type "asi" to load some results 3. Scroll down to click on "Load More" button a. This will add params in the url bar like
<https://recipe-search.typesense.org/?r%5Bquery%5D=asi&r%5Bpage%5D=2>
4. Now manually change page to
-2
or anything negative 5. This will throw the error in the console.
f
Result pages start counting from 1 onwards. Is there a reason for accessing a negative page?
p
Ideally there's no reason to access from negative page. But we have seen many reports of this error in sentry. Might be some bad players trying to exploit it.
f
Yeah, it's not possible by design. Can't figure out what might be prompting them to try to access a negative page. Maybe -1 being the last one? (Like how Python deals with arrays)
p
The problem is, it throws 500 Internal Server Error, and I wanna prevent that. But that problem only happens in Production, but not locally.
f
What's the behavior locally?
p
It removes negative page params from the URL bar and throws unsigned int error in console. And there's no 500 Internal Server Error happens there.
f
Next.js errors in production will always result in `500`s. Even if it's an external service throwing it
p
That's something new I learned today.
Thanks for the help man!
🙌 1