feat: 迁移到Cloudflare Workers并重构API请求处理
refactor: 使用fetch替换axios并优化请求处理逻辑 docs: 添加DEPLOYMENT.md部署指南 build: 更新package.json依赖和脚本配置 style: 更新组件类型定义和注释 perf: 优化图片代理和用户数据初始化逻辑
This commit is contained in:
30
.wrangler/tmp/bundle-MMP94b/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-MMP94b/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user