From 01c22a02558a1be4d2f068823d0b0e557f8889f9 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sat, 23 May 2026 04:46:59 +0000
Subject: [PATCH 1/4] Use remote camera URL as-is instead of rewriting host to
printer IP
---
js/index.js | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/js/index.js b/js/index.js
index 8385633..b144c24 100644
--- a/js/index.js
+++ b/js/index.js
@@ -455,16 +455,18 @@ $(document).ready(function() {
$cameraList.empty();
cams.forEach(function(cam) {
- // Extract path from cam.stream_url (remove protocol and host if present)
- let streamPath = cam.stream_url;
+ // If cam.stream_url is an absolute URL (e.g. a remote camera
+ // hosted on a different IP), use it as-is so we don't rewrite
+ // the host to the printer's IP. Otherwise treat it as a path
+ // relative to the printer and prepend the printer URL.
+ let streamUrl;
try {
- const url = new URL(cam.stream_url);
- streamPath = url.pathname + url.search;
+ // new URL() throws for relative paths
+ new URL(cam.stream_url);
+ streamUrl = cam.stream_url;
} catch (e) {
- // If not a full URL, use as-is (already a path)
- streamPath = cam.stream_url;
+ streamUrl = printerUrl(ip, cam.stream_url);
}
- const streamUrl = printerUrl(ip, streamPath);
const snapshotUrl = streamUrl.replace('?action=stream', '?action=snapshot');
const cameraOption = `
@@ -534,11 +536,13 @@ $(document).ready(function() {
}
const selectedIp = $('#printerIp').val();
- const webcamPath = selectedUrl.split(selectedIp)[1]; // Extract the path part
-
+
// Update variables directly
printerIp = selectedIp; // Update the global variable
- WebcamPath = webcamPath;
+ // Store the resolved camera URL as-is. It may live on a different host
+ // than the printer (e.g. a remote camera), so we must not rebuild it
+ // from printerIp later.
+ WebcamPath = selectedUrl;
// Reset flip button states first
$('#flip-horizontal, #flip-vertical').removeClass('btn-primary').addClass('btn-secondary');
@@ -546,7 +550,7 @@ $(document).ready(function() {
// Update UI and set flip states
const $zoomImage = $("#zoom-image");
$zoomImage
- .attr("src", printerUrl(printerIp, WebcamPath))
+ .attr("src", selectedUrl)
.data('flip-h', flipHorizontal)
.data('flip-v', flipVertical);
From 816c9dc3289b6c7e7bdf0a42e75a4c5afa0949c7 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sat, 23 May 2026 05:10:33 +0000
Subject: [PATCH 2/4] Add optional camera IP override for cameras on a separate
host
---
index.html | 14 ++++++++++++++
js/index.js | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/index.html b/index.html
index 4cc03ad..127c0ae 100644
--- a/index.html
+++ b/index.html
@@ -94,6 +94,20 @@
Printer Configuration
+
+
+
+
+
+ Use this if the camera is hosted on a different device than the printer.
+
+
+ Invalid camera IP address format
+
+
+
diff --git a/js/index.js b/js/index.js
index b144c24..d7ed6af 100644
--- a/js/index.js
+++ b/js/index.js
@@ -9,6 +9,26 @@ function printerUrl(ip, endpoint) {
return `http://${ip}${endpoint}`;
}
+// Rewrite the host of a URL (absolute or relative-to-printer) to use a
+// different host. Used to point the camera feed at a separate device than
+// the printer (e.g. printer on 192.168.1.196, camera on 192.168.1.197).
+function rewriteHost(url, newHost) {
+ if (!newHost) return url;
+ newHost = newHost.replace(/^https?:\/\//, '');
+ try {
+ const parsed = new URL(url);
+ // Preserve protocol, path, query and fragment; only swap host[:port].
+ // The user-supplied host may include its own :port, which overrides.
+ const hostHasPort = /:\d+$/.test(newHost);
+ parsed.host = newHost;
+ if (!hostHasPort) parsed.port = '';
+ return parsed.toString();
+ } catch (e) {
+ // Relative URL (path) - build an absolute URL against the new host.
+ return `http://${newHost}${url.startsWith('/') ? '' : '/'}${url}`;
+ }
+}
+
function isValidIP(input) {
input = input.trim();
if (!input) return false;
@@ -422,6 +442,17 @@ $(document).ready(function() {
let ip = $('#printerIp').val();
// Strip http:// or https:// when saving the IP
ip = ip.replace(/^https?:\/\//, '');
+
+ // Optional camera IP override (for cameras hosted on a different device
+ // than the printer). If blank, the printer IP is used as the camera host.
+ let camIp = ($('#cameraIp').val() || '').trim().replace(/^https?:\/\//, '');
+ $('#cameraIpError').hide();
+ if (camIp && !isValidIP(camIp)) {
+ $('#cameraIpError').show();
+ return;
+ }
+ const cameraHost = camIp || ip;
+
if (isValidIP(ip)) {
console.log('Checking printer connection:', ip);
@@ -440,6 +471,7 @@ $(document).ready(function() {
// Disable IP input and show disconnect button
$('#printerIp').prop('disabled', true);
+ $('#cameraIp').prop('disabled', true);
$('#disconnectBtn').show();
// Fetch camera list
@@ -467,6 +499,11 @@ $(document).ready(function() {
} catch (e) {
streamUrl = printerUrl(ip, cam.stream_url);
}
+ // If the user provided a separate camera IP, point the
+ // stream at that host instead of the printer.
+ if (camIp) {
+ streamUrl = rewriteHost(streamUrl, cameraHost);
+ }
const snapshotUrl = streamUrl.replace('?action=stream', '?action=snapshot');
const cameraOption = `
@@ -642,6 +679,7 @@ $(document).ready(function() {
// Enable IP input
$('#printerIp').prop('disabled', false);
+ $('#cameraIp').prop('disabled', false);
// Hide disconnect button
$(this).hide();
From 5cbe11098739ad94ce0c2db5606a8e2380e58e2a Mon Sep 17 00:00:00 2001
From: Warren
Date: Sat, 23 May 2026 07:35:32 +0200
Subject: [PATCH 3/4] Update install.sh
---
install.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/install.sh b/install.sh
index 42d52ff..8a9dfca 100755
--- a/install.sh
+++ b/install.sh
@@ -3,7 +3,7 @@
# Default values
AXISCOPE_ENV="axiscope-env"
INSTALL_DIR="$HOME/axiscope"
-REPO_URL="https://github.com/nic335/Axiscope.git"
+REPO_URL="https://github.com/warrendt/Axiscope.git"
BRANCH="main"
# Parse command line arguments
@@ -202,4 +202,4 @@ echo "The service can be controlled through Mainsail's service control popup"
# Get and display the printer's IP address
PRINTER_IP=$(hostname -I | awk '{print $1}')
-echo "When running, it will be hosted at http://${PRINTER_IP}:3000"
\ No newline at end of file
+echo "When running, it will be hosted at http://${PRINTER_IP}:3000"
From 7b7ffe3c8e35dc48ceb71c1c8e9c8199785a229b Mon Sep 17 00:00:00 2001
From: Warren
Date: Sun, 24 May 2026 21:25:13 +0200
Subject: [PATCH 4/4] Revert "Update install.sh"
This reverts commit 5cbe11098739ad94ce0c2db5606a8e2380e58e2a.
---
install.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/install.sh b/install.sh
index 8a9dfca..42d52ff 100755
--- a/install.sh
+++ b/install.sh
@@ -3,7 +3,7 @@
# Default values
AXISCOPE_ENV="axiscope-env"
INSTALL_DIR="$HOME/axiscope"
-REPO_URL="https://github.com/warrendt/Axiscope.git"
+REPO_URL="https://github.com/nic335/Axiscope.git"
BRANCH="main"
# Parse command line arguments
@@ -202,4 +202,4 @@ echo "The service can be controlled through Mainsail's service control popup"
# Get and display the printer's IP address
PRINTER_IP=$(hostname -I | awk '{print $1}')
-echo "When running, it will be hosted at http://${PRINTER_IP}:3000"
+echo "When running, it will be hosted at http://${PRINTER_IP}:3000"
\ No newline at end of file