Solve matrix equation $XAX^*=B$ for $X$ in least squares sense How can the following optimization problem be solved?
$$\arg\min_{\mathbf{X} \in \mathcal{C}^{n \times m}} \left\Vert \mathbf{X}\mathbf{A}\mathbf{X}^* - \mathbf{B} \right\Vert_F$$
where $\mathbf{A} \in \mathcal{C}^{m \times m}$ and $\mathbf{B} \in \mathcal{C}^{n \times n}$ are Hermitian, with $m > n$, generally. Matrix $\mathbf{A}$ is diagonal and invertible. Let $^*$ denote the conjugate transpose.

Solution attempt
Solution attempt was wrong, see comments. See the answers for a better attempt.
I realize it is possible to take the derivative of the expression and equating it to zero, but I end up with the following expression I have trouble with
$\require{enclose}
     \enclose{horizontalstrike}{\frac{d}{d \mathbf{X}}\mathrm{Tr}\left( \mathbf{X}\mathbf{A}\mathbf{X}^* \mathbf{X}\mathbf{A}\mathbf{X}^* - 2\mathbf{X}\mathbf{A}\mathbf{X}^*\mathbf{B} + \mathbf{B}^*\mathbf{B} \right) = 0}$
$\require{enclose}
     \enclose{horizontalstrike}{\mathbf{X}\mathbf{A}\mathbf{X}^* \mathbf{X}\mathbf{A} - \mathbf{B}\mathbf{X}\mathbf{A} = 0}$
Because $\require{enclose}
     \enclose{horizontalstrike}{\mathbf{A}}$ is invertible
$\require{enclose}
     \enclose{horizontalstrike}{\mathbf{X}\mathbf{A}\mathbf{X}^*\mathbf{X} - \mathbf{B}\mathbf{X} = 0}$
Which does not seem any simpler.
Variant
Would the following variant be harder to solve? I don't see it working with Måren W's answer below
$\underset{\mathbf{X}}{\mathrm{argmin}} \left\Vert \mathbf{X}\mathbf{A}\mathbf{X}^T - \mathbf{B} \right\Vert_F$
with $m > n$. Again the matrices are complex, but now $\mathbf{A}$ is a symmetric (not Hermitian), diagonal and invertible matrix and $\mathbf{B}$ is also symmetric.
 A: For the special case where $\mathbf{A}$ and $\mathbf{B}$ are positive definite ($\mathbf{B}$ can be positive semidefinite), we may do as follows:
Let $\mathbf{A}=\mathbf{U}_1\mathbf{\Sigma}_1\mathbf{U}_1^*$ be a singular value decomposition of $\mathbf{A}$, and let $\tilde{\mathbf{B}}=\mathbf{U}_2\mathbf{\Sigma}_2\mathbf{U}_2^*$ be a singular value decomposition of the zero padded matrix
$$
\tilde{\mathbf{B}} =
\begin{bmatrix}
    \mathbf{B} & \mathbf{0} \\
    \mathbf{0} & \mathbf{0}
\end{bmatrix}
\in\mathcal{C}^{m\times m}.
$$
Then
$$
\lVert\tilde{\mathbf{X}}\mathbf{A}\tilde{\mathbf{X}}^*-\tilde{\mathbf{B}}\rVert_F =
\lVert\tilde{\mathbf{X}}\mathbf{U}_1\mathbf{\Sigma}_1\mathbf{U}_1^*\tilde{\mathbf{X}}^*-\mathbf{U}_2\mathbf{\Sigma}_2\mathbf{U}_2^*\rVert_F =
\lVert\mathbf{U}_2^*\tilde{\mathbf{X}}\mathbf{U}_1\mathbf{\Sigma}_1\mathbf{U}_1^*\tilde{\mathbf{X}}^*\mathbf{U}_2-\mathbf{\Sigma}_2\rVert_F.
$$
This is zero (and thus minimal) if
$\mathbf{U}_2^*\tilde{\mathbf{X}}\mathbf{U}_1\sqrt{\mathbf{\Sigma}_1}=\sqrt{\mathbf{\Sigma}_2}$, i.e. when
$$
\tilde{\mathbf{X}}=\mathbf{U}_2\sqrt{\mathbf{\Sigma}_2\mathbf{\Sigma}_1^{-1}}\mathbf{U}_1^*.
$$
Now, if $\mathbf{X}$ is the topmost $n\times m$ submatrix of $\tilde{\mathbf{X}}$, then
$$
\lVert\mathbf{X}\mathbf{A}\mathbf{X}^*-\mathbf{B}\rVert_F = 0.
$$
A: I write some remarks.
I see that the OP did not remove his false derivative...
Remark 1. Let $si(A)=(p+,q-)$ be the signature of $A$. Then the signature of $XAX^*$ has the form $si(B)=(u+,v-,w0)$ where $u\leq p,v\leq q$. In particular, if $A> 0$, then $XAX^*\geq 0$.
Then, in general, there is no $X$ st $XAX^*=B$.
Remark 2. We may assume that $B$ is a diagonal real matrix. (cf. the Marten's calculation).
Remark 3. If $A>0,B\leq 0$ then $\inf||XAX^*-B||=||B||$.
Indeed, $||XAX^*-B||^2=tr((R+S)^2)$ where $R=XAX^*\geq0,S=-B\geq 0$. Clearly $tr((R+S)^2)\geq tr(S^2)=||B||^2$.
Remark 4. If $si(B)=(u+,v-,w0)$ with $u\leq p,v\leq q$, then there is $X$ st $XAX^*=B$.
Indeed, since a permutation is orthogonal, we may assume $A=diag(U_{u},V_{v},W_{m-u-v})$ where $U,V,W$ are diagonal, $U>0,V<0$ and $B=diag(P_u,Q_v,0_{n-u-v})$ where $P,Q$ are diagonal and $P>0,Q<0$. There is 
$Y\in  GL_{u+v}$ st $Ydiag(U,V)Y^*=diag(P,Q)$.
Then $X=\begin{pmatrix}Y&0_{u+v,m-u-v}\\0_{w,u+v}&0_{w,m-u-v}\end{pmatrix}$ is a required solution.
EDIT. Some toy examples seem to show that the following conjecture is true (but I am not sure).
$\textbf{Conjecture}$. The lower bound of $||XAX^*-B||$ is reached for some $X$ st $XAX^*$ is diagonal.
If this is true, then we are done, as shows the following example
$si(A)=(2+,2-)$ and $B=diag(a,2,1)$ where $a\geq0$.
If $a>1$, then a best approximation is $diag(a,2,0)$.
If $a=1$, then two best approx are $diag(1,2,0),diag(0,2,1)$.
If $a<1$, then a best approx is $diag(0,2,1)$.
