Files
pixivnow/.wrangler/tmp/bundle-z3POAk/checked-fetch.js
JuLuogo 32956bad14 refactor(functions): 重构静态资源处理逻辑,使用getAssetFromKV和ASSETS API
优化静态资源处理逻辑,移除自定义的handleStaticAssets函数,改用Cloudflare的getAssetFromKV和ASSETS API
添加对SPA路由的支持,当资源不存在时返回index.html
更新依赖并清理不再使用的代码
2025-10-08 16:24:59 +08:00

31 lines
833 B
JavaScript

const urls = new Set();
function checkURL(request, init) {
const url =
request instanceof URL
? request
: new URL(
(typeof request === "string"
? new Request(request, init)
: request
).url
);
if (url.port && url.port !== "443" && url.protocol === "https:") {
if (!urls.has(url.toString())) {
urls.add(url.toString());
console.warn(
`WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:\n` +
` - ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.\n`
);
}
}
}
globalThis.fetch = new Proxy(globalThis.fetch, {
apply(target, thisArg, argArray) {
const [request, init] = argArray;
checkURL(request, init);
return Reflect.apply(target, thisArg, argArray);
},
});