Suppose that I have $g(x)=\frac{1}{x}$ we know that the domain is all real numbers except 0 and $f(g(x))=\frac{2}{x}+5$. we know the domain is also all real numbers except 0 We know that to find $f(x)$, what we have to do is find the inverse function of $g(x)$, which is $g^{-1}(x)=\frac{1}{x}$. Then we substitute it and get $f(g(g^{-1}(x)))=2x+5$, so that $f(x)=2x+5$.
Does it affect the domain of $f(x)$? I mean, when you substitute $x$ with $g^{-1}(x)$ to $f(g(x))$, then the domain of $f(x)$ must be the domain of $g^{-1}(x)$, right (that is the domain of $f(x)$ is $x$ not $0$ which is same as the domain of $g^{-1}(x)$)? Please correct me if I am wrong.