The Polyakov action for strings reads
$$ S[X] = -\frac{T}{2} \int d^2\sigma\, \sqrt{h}h^{\alpha\beta} \partial_\alpha X^\mu \partial_\beta X_\mu, $$
from which the Virasoro constraints follow:
$$ T_{\alpha\beta} = -\frac{2}{T} \frac{1}{\sqrt{h}} \frac{\delta S}{\delta h^{\alpha\beta}} = 0. $$
In classic textbooks such as that of Green, Schwarz, and Witten, it is stated that plugging in $T_{\alpha\beta}=0$ to the action transforms the Polyakov action to its alternative, the Nambu-Goto action.
However, according to Dirac's constrained dynamics, it is not automatically justified to put a constraint equation into the action since it may alter the variational condition, potentially leading to nonsensical equations of motion.
To my understanding, such manipulation is allowed only for the first-class constraints, i.e. those with vanishing Poisson bracket with other constraints. In this context, how can one show that using the Virasoro constraints to transform Polyakov action into the Nambu-Goto action?