In this study, we assess the effectiveness of portable near-infrared (NIR) spectroscopy coupled with advanced machine learning algorithms for on-site detection and quantification of key explosive precursors, in accordance with EU Regulation 2019/1148. The research focuses on developing robust quantitative models for hydrogen peroxide, nitromethane, and nitric acid, addressing the challenge of varied concentrations and compositions encountered by first responders. The models demonstrated high predictive accuracy, with Root Mean Square Error of Prediction (RMSEP) values of 0.96 % for hydrogen peroxide, 2.46 % for nitromethane, and 0.70 % for nitric acid across diverse samples. The qualitative models created for those explosives precursors also showed high effectiveness and reliability, with minimal false negatives and false positives. The integration of machine learning algorithms facilitated the adaptation of these models to handle the complex variability of precursor formulations effectively. Additionally, the utilization of cloud operating systems provided significant advantages for real-time analysis and continuous data updating, essential for maintaining the accuracy and relevance of the models in rapidly changing field conditions. This research highlights the potential of integrating advanced spectroscopic techniques and machine learning within a cloud-based framework to improve the detection and management of explosive precursors in field settings. This integration enables the reliable detection and quantification of these precursors in a matter of seconds. Future work will extend this approach to additional precursors and explore complementary technologies to further enhance on-site detection capabilities.