mirror of
https://github.com/ad1217/PrinterStatus
synced 2024-11-21 23:13:49 -05:00
Transform relative webcam URL into absolute
This commit is contained in:
parent
e2f5d9d0c0
commit
ebc24fdfc2
@ -48,7 +48,7 @@ app.get('/webcam/:printer', (req, res) => {
|
|||||||
let printer: PrinterStatus | undefined = printerStatuses.find(
|
let printer: PrinterStatus | undefined = printerStatuses.find(
|
||||||
p => p.name === req.params.printer
|
p => p.name === req.params.printer
|
||||||
);
|
);
|
||||||
if (printer && printer.webcamURL) {
|
if (printer?.webcamURL) {
|
||||||
req.url = ''; // truncate the url for passing to the proxy
|
req.url = ''; // truncate the url for passing to the proxy
|
||||||
proxy.web(req, res, { target: printer.webcamURL });
|
proxy.web(req, res, { target: printer.webcamURL });
|
||||||
} else res.status(404).send('Not Found: Printer not known or has no webcam.');
|
} else res.status(404).send('Not Found: Printer not known or has no webcam.');
|
||||||
@ -84,6 +84,9 @@ class PrinterStatus {
|
|||||||
// TODO: error handling (try/catch)
|
// TODO: error handling (try/catch)
|
||||||
const settings = await this.api_get('settings');
|
const settings = await this.api_get('settings');
|
||||||
this.webcamURL = settings.webcam.streamUrl;
|
this.webcamURL = settings.webcam.streamUrl;
|
||||||
|
if (this.webcamURL?.startsWith('/')) {
|
||||||
|
this.webcamURL = this.address + this.webcamURL;
|
||||||
|
}
|
||||||
this.name = settings.appearance.name;
|
this.name = settings.appearance.name;
|
||||||
|
|
||||||
// do passive login to get a session key from the API key
|
// do passive login to get a session key from the API key
|
||||||
|
Loading…
Reference in New Issue
Block a user