mirror of
https://github.com/movie-web/providers-api.git
synced 2025-09-13 12:13:26 +00:00
@@ -9,9 +9,21 @@ export function getProviders(context: Context<Env>) {
|
||||
const specialDomains = specialDomainsEnv.split(",").map(v=>v.trim()).filter(v=>v.length>0);
|
||||
|
||||
const fetcher: RealFetcher = (u,ops) => {
|
||||
const url = new URL(u);
|
||||
let url: URL | null = null;
|
||||
try {
|
||||
if (ops.baseUrl) {
|
||||
const baseUrl = ops.baseUrl.endsWith("/") ? ops.baseUrl.slice(0, -1) : ops.baseUrl;
|
||||
const path = u.startsWith("/") ? u : u.slice(0, -1);
|
||||
url = new URL(baseUrl + path);
|
||||
} else {
|
||||
url = new URL(u);
|
||||
}
|
||||
if (specialDomains.includes(url.hostname) && !!proxyUrl)
|
||||
return makeSimpleProxyFetcher(proxyUrl, fetch)(u, ops);
|
||||
} catch {
|
||||
return standardFetcher(u, ops);
|
||||
}
|
||||
|
||||
return standardFetcher(u, ops);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user