Why i cant use getUserMedia() in express html

When I run the html with the VScode live server, everything runs normally and the script inserted with get the media normally, but when I start serving this html through an express server, the navigator.mediaDevices.getUserMedia( ) doesn’t work as it returns null//undefined, how to solve?