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/api/Device.ts b/browse-next/src/api/Device.ts index ac66dbb5..d2274566 100644 --- a/browse-next/src/api/Device.ts +++ b/browse-next/src/api/Device.ts @@ -8,13 +8,13 @@ import type { GroupId as ProjectId, IsoFormattedDateString, LatLng, + ScheduleId, } from "@typedefs/api/common"; import type { ApiDeviceHistorySettings, ApiDeviceResponse, ApiMaskRegionsData, } from "@typedefs/api/device"; -import type { ScheduleId } from "@typedefs/api/common"; import type { DeviceConfigDetail, DeviceEvent, @@ -24,6 +24,7 @@ import type { DeviceEventType } from "@typedefs/api/consts"; import type { ApiStationResponse as ApiLocationResponse } from "@typedefs/api/station"; import type { ApiRecordingResponse } from "@typedefs/api/recording"; import type { ApiTrackResponse } from "@typedefs/api/track"; + export const createProxyDevice = ( projectNameOrId: string, deviceName: string @@ -678,7 +679,7 @@ export const getDeviceModel = async (deviceId: DeviceId) => { return model; } } - const model = await getLatestEventsByDeviceId(deviceId, { + return await getLatestEventsByDeviceId(deviceId, { type: "versionData", limit: 1, }).then((response) => { @@ -690,7 +691,6 @@ export const getDeviceModel = async (deviceId: DeviceId) => { return null; } }); - return model; } catch (e) { return null; } diff --git a/browse-next/src/components/DeviceRecordingSetup.vue b/browse-next/src/components/DeviceRecordingSetup.vue index 3f14cab6..2b2d57e0 100644 --- a/browse-next/src/components/DeviceRecordingSetup.vue +++ b/browse-next/src/components/DeviceRecordingSetup.vue @@ -667,10 +667,10 @@ watch(customRecordingWindowStop, async () => {
(() => { 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(() => {