diff --git a/src/libs/getCurrentDomain.ts b/src/libs/getCurrentDomain.ts index d9bba18..8c3b4c2 100644 --- a/src/libs/getCurrentDomain.ts +++ b/src/libs/getCurrentDomain.ts @@ -1,10 +1,30 @@ import type { HonoRequest } from "hono"; -export function getCurrentDomain(req: HonoRequest) { +export function getCurrentDomain(req: HonoRequest): string | undefined; +export function getCurrentDomain( + req: HonoRequest, + avoidLocalhost: false, +): string; +export function getCurrentDomain( + req: HonoRequest, + avoidLocalhost: true, +): string | undefined; +export function getCurrentDomain(req: HonoRequest, avoidLocalhost = true) { let domain = req.url.replace(req.path, ""); if (domain.includes("?")) { domain = domain.split("?")[0]; } + if (avoidLocalhost) { + if ( + domain.includes("localhost") || + domain.includes("127.0.0.1") || + domain.includes("192.168.1") + ) { + console.log("Domain is localhost, returning undefined"); + return; + } + } + return domain; } diff --git a/src/libs/maybeScheduleNextAiringEpisode.ts b/src/libs/maybeScheduleNextAiringEpisode.ts index 59b2239..65d0ee6 100644 --- a/src/libs/maybeScheduleNextAiringEpisode.ts +++ b/src/libs/maybeScheduleNextAiringEpisode.ts @@ -18,11 +18,7 @@ export async function maybeScheduleNextAiringEpisode( aniListId: number, ) { const domain = getCurrentDomain(req); - if ( - domain.includes("localhost") || - domain.includes("127.0.0.1") || - domain.includes("192.168.1") - ) { + if (!domain) { return; }