From 7e447fd8f478fd3f980f9b44ace29abc7fdffb04 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 27 Mar 2026 08:28:30 +0000 Subject: refactor(proxy): move manga chapter counts behind indexed cache --- src/lib/Utility/proxy.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/lib/Utility/proxy.ts') diff --git a/src/lib/Utility/proxy.ts b/src/lib/Utility/proxy.ts index 32f31226..57883836 100644 --- a/src/lib/Utility/proxy.ts +++ b/src/lib/Utility/proxy.ts @@ -1,11 +1,24 @@ +import { env } from "$env/dynamic/public"; import { isLocalApp } from "$lib/Utility/appOrigin"; +const DEFAULT_PROXY_ORIGIN = "https://proxy.due.moe"; + +const normaliseOrigin = (origin: string) => + origin.endsWith("/") ? origin.slice(0, -1) : origin; + +export const proxyOrigin = () => + normaliseOrigin(env.PUBLIC_PROXY_ORIGIN || DEFAULT_PROXY_ORIGIN); + +export const proxyRoute = (path = "/") => + `${proxyOrigin()}${path.startsWith("/") ? path : `/${path}`}`; + export const proxy = (url: string, disable = false) => { const randomKey = Math.floor(Math.random() * 90) + 10; + const forcedProxy = Boolean(env.PUBLIC_PROXY_ORIGIN); - return isLocalApp() && !disable + return isLocalApp() && !disable && !forcedProxy ? url - : `https://proxy.due.moe/?d2=${btoa( + : `${proxyOrigin()}/?d2=${btoa( url .split("") .map((char) => char.charCodeAt(0) + randomKey) -- cgit v1.2.3