diff --git a/src/controllers/internal/new-episode/index.ts b/src/controllers/internal/new-episode/index.ts index c81c5f7..8649db7 100644 --- a/src/controllers/internal/new-episode/index.ts +++ b/src/controllers/internal/new-episode/index.ts @@ -8,6 +8,7 @@ import { z } from "zod"; import { Case, changeStringCase } from "~/libs/changeStringCase"; import type { AdminSdkCredentials } from "~/libs/fcm/getGoogleAuthToken"; import { sendFcmMessage } from "~/libs/fcm/sendFcmMessage"; +import { getCurrentDomain } from "~/libs/getCurrentDomain"; import { verifyQstashHeader } from "~/libs/qstash/verifyQstashHeader"; import { readEnvVariable } from "~/libs/readEnvVariable"; import { getTokensSubscribedToTitle } from "~/models/token"; @@ -42,7 +43,7 @@ app.post( return c.json(ErrorResponse, { status: 401 }); } - const domain = c.req.url.replace(c.req.path, ""); + const domain = getCurrentDomain(c.req); const { success, result: fetchEpisodesResult } = await fetch( `${domain}/episodes/${aniListId}`, ).then((res) => res.json()); diff --git a/src/libs/getCurrentDomain.ts b/src/libs/getCurrentDomain.ts new file mode 100644 index 0000000..4e2af8c --- /dev/null +++ b/src/libs/getCurrentDomain.ts @@ -0,0 +1,5 @@ +import type { HonoRequest } from "hono"; + +export function getCurrentDomain(req: HonoRequest) { + return req.url.replace(req.path, ""); +}