You have diagnosed it correctly, which puts you ahead of most reports like this. The browser received HR's content; hiding it in the component was never a control.
Move the filter into the query and derive the team from the session, never from a parameter the client sends:
const { data } = await supabase.from('pages')
.select('id,title,excerpt')
.textSearch('body', q)with an RLS policy on pages restricting to the caller's team memberships. Then /api/pages cannot return HR rows even if someone calls it directly with curl, which they now know they can.
One more thing: treat the HR content as disclosed. Whoever searched saw it, and anyone with the browser console saw more.