diff options
| author | Fuwn <[email protected]> | 2026-03-27 08:28:30 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-03-27 08:45:37 +0000 |
| commit | 7e447fd8f478fd3f980f9b44ace29abc7fdffb04 (patch) | |
| tree | 31cd06a778ece94b14590ecef88c9f08ac456732 /src/lib/Utility | |
| parent | chore(apps): Remove placeholder README (diff) | |
| download | due.moe-7e447fd8f478fd3f980f9b44ace29abc7fdffb04.tar.xz due.moe-7e447fd8f478fd3f980f9b44ace29abc7fdffb04.zip | |
refactor(proxy): move manga chapter counts behind indexed cache
Diffstat (limited to 'src/lib/Utility')
| -rw-r--r-- | src/lib/Utility/proxy.ts | 17 |
1 files changed, 15 insertions, 2 deletions
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) |