// Giithub @BlueSkyXN // Code: Modified based on the original // 仅供学习CloudFlare Worker开发使用,违规使用后果自负 // License @GPLv3 addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { if (request.method === 'GET') { return new Response(html, { headers: { 'content-type': 'text/html;charset=UTF-8', }, }) } else if (request.method === 'POST') { const formData = await request.formData() const file = formData.get('file') const response = await fetch("https://community.codewave.163.com/gateway/lowcode/api/v1/app/upload", { method: 'POST', headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36', 'Referer': 'https://community.codewave.163.com' }, body: formData }) const data = await response.json() let uploadUrl = data.result; // Calculate the equivalent URL const originalBase = "https://lcap-static-saas.nos-eastchina1.126.net/"; const newBase = "https://community.codewave.163.com/upload/"; let equivalentUrl = uploadUrl.replace(originalBase, newBase); return new Response(JSON.stringify({ uploadUrl, equivalentUrl }), { headers: { 'Content-Type': 'application/json' } }) } } const html = `
该源码开源,仅供学习JS使用,违规使用后果自负