Suppose I have
$\sqrt{r-x}-\frac{x}{\sqrt{r-x}}-o=0$ with $r,x$ and $o$ real.
To solve I multiply by $\sqrt{r-x}$. I assume therefore $r>x$
$r-x-x-o\sqrt{r-x}=0$
$r-2x=o\sqrt{r-x}$
Squaring
$(r-2x)^2=o^2(r-x)$
This is a second order equation,whose solutions are
$x= \frac{r}{2} -\frac{o^2}{8} \pm \frac{o\sqrt{o^2+8r}}{8}$
However, for instance, for $r=1$ and $o=1/2$ I get two solutions. For both $x<1$, however only one is actually a solution.
How can I avoid to introduce a spurious solution?
The spurious solution is introduced by the squaring. Before squaring, $r-2x$ is constrained to have the sign of $o$ (as the square root is a positive number). When squaring, you drop this condition.
Alternative resolution:
Let $z:=\sqrt{r-x}>0$.
The equation becomes
$$z-\frac{r-z^2}z-o=0$$
or
$$2z^2-oz-r=0.$$
The only positive solutions in $z$ is
$$z=\frac{o\color{green}+\sqrt{o^2+8r}}4.$$
It exist iff $o^2+8r\ge0$, and $x=r-z^2$ is implicitly $\le r$.