From d7d294bc6078d1165bb2a363ef27df802e4cd8b3 Mon Sep 17 00:00:00 2001 From: jon Date: Wed, 20 Nov 2024 09:37:49 +1300 Subject: [PATCH] - Fix request host headers if they get re-written to default to browse-next - Always allow showing device recordings, even when there's no current location set. --- api/Server.ts | 6 ++++++ browse-next/src/views/DevicesView.vue | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/api/Server.ts b/api/Server.ts index 7b6f3065..5ff370c1 100755 --- a/api/Server.ts +++ b/api/Server.ts @@ -149,6 +149,12 @@ const checkS3Connection = async (): Promise => { "Access-Control-Allow-Headers", "where, offset, limit, Authorization, Origin, X-Requested-With, Content-Type, Accept, Viewport, if-none-match, cache-control" ); + + // NOTE: We've seen an instance where the HOST request header is rewritten by the client, which would otherwise break + // some things. If the host is unknown, default to browse-next. + if (!request.headers.host.includes("cacophony.org.nz")) { + request.headers.host = "https://browse-next.cacophony.org.nz"; + } next(); }); await initialiseApi(app); diff --git a/browse-next/src/views/DevicesView.vue b/browse-next/src/views/DevicesView.vue index 82df4fb2..fff90be0 100644 --- a/browse-next/src/views/DevicesView.vue +++ b/browse-next/src/views/DevicesView.vue @@ -506,6 +506,10 @@ const deviceRecordingMode = computed<"cameras" | "audio">(() => { return "cameras"; }); +const cacophonyEpoch = new Date(); +cacophonyEpoch.setFullYear(2010, 0, 0); +cacophonyEpoch.setHours(0, 0, 0); + const isDevicesRoot = computed(() => { return route.name === "devices"; }); @@ -538,14 +542,13 @@ const isDevicesRoot = computed(() => {