I'm working on the following exercise (not homework) from Ahlfors' text:

" If $f(z)$ is analytic in $|z| \leq 1$ and satisfies $|f| = 1$ on $|z| = 1$, show
that $f(z)$ is rational."

I already know about the reflection principle for the case of a half plane, so I tried using the "Cayley transform" $$T (\zeta)=\frac{\zeta-i}{\zeta+i}$$
Which maps the closed upper half plane onto the closed unit disk with $1$ removed.

I defined $$g(\zeta)=(T^{-1} \circ f \circ T)(\zeta)=i\frac{1+f \left( \frac{\zeta-i}{\zeta+i} \right)}{1-f \left( \frac{\zeta-i}{\zeta+i} \right)},$$
And tried to apply the reflection principle in the book. $g$ is indeed analytic in the upper half plane, but for $\zeta \in \mathbb R$, I'm afraid that $g$ might get infinite (because on the boundary, $f$ takes values on the unit circle). If so, it will not be continuous and not even real, and the reflection principle is not applicable.

Am I missing something here? After all Ahlfors does mention in the text a generalized reflection principle for arbitrary circles $C,C'$.

Thanks