diff --git a/motioneye/handlers/picture.py b/motioneye/handlers/picture.py index 386bffc59..7deb7e77a 100644 --- a/motioneye/handlers/picture.py +++ b/motioneye/handlers/picture.py @@ -252,6 +252,8 @@ async def list(self, camera_id): raise HTTPError(400, 'unknown operation') async def frame(self, camera_id): + self.set_header('Cache-Control', 'private, no-store, must-revalidate') + camera_config = config.get_camera(camera_id) if ( diff --git a/motioneye/static/js/frame.js b/motioneye/static/js/frame.js index c12c81206..23d844686 100644 --- a/motioneye/static/js/frame.js +++ b/motioneye/static/js/frame.js @@ -82,6 +82,10 @@ function refreshCameraFrame() { if (cameraFrame.proto == 'mjpeg') { /* no manual refresh for simple mjpeg cameras */ + if (!cameraFrame.url) { + return; /* the stream URL is withheld until login */ + } + var url = cameraFrame.url.replace('127.0.0.1', window.location.host.split(':')[0]); url += (url.indexOf('?') > 0 ? '&' : '?') + '_=' + new Date().getTime(); img.src = url; diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js index 7efe4d133..0e62f6729 100644 --- a/motioneye/static/js/main.js +++ b/motioneye/static/js/main.js @@ -5494,6 +5494,10 @@ function doAuth() { if (!frame) { fetchCurrentConfig(endProgress); } + else if (!currentUser && $('div.camera-frame').attr('proto') == 'mjpeg') { + /* for an mjpeg camera we reload after login, so the URL is fetched */ + window.location.reload(); + } } else { // Session invalid, show login dialog runLoginDialog(function () { diff --git a/motioneye/templates/main.html b/motioneye/templates/main.html index fe6fc172c..db8dbf644 100644 --- a/motioneye/templates/main.html +++ b/motioneye/templates/main.html @@ -1360,7 +1360,7 @@ {% else %}