We study a time-independent nonlinear Schrödinger equation with an attractive inverse square potential and a nonautonomous nonlinearity whose power is the critical Sobolev exponent. The problem shares a strong resemblance with the prescribed scalar curvature problem on the standard sphere. Particular attention is paid to the blow-up possibilities, i.e. the critical points at infinity of the corresponding variational problem. Due to the strong singularity in the potential, some new phenomenon appear. A complete existence result is obtained in dimension 4 using a detailed analysis of the gradient flow lines.