Files
pixivnow/.wrangler/tmp/bundle-Zpyo5X/checked-fetch.js
JuLuogo 0faea53617 feat: 添加前端页面处理和静态资源支持
- 移除测试端点,添加前端页面处理逻辑
- 实现静态资源处理功能
- 添加SPA路由支持,所有未匹配路径返回前端页面
- 更新依赖,添加@cloudflare/kv-asset-handler
2025-10-08 16:15:24 +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);
},
});