diff --git a/README.md b/README.md index 41b2c5441..9c540cd59 100644 --- a/README.md +++ b/README.md @@ -3,26 +3,6 @@ 免费图片托管解决方案,Flickr/imgur 替代品。使用 Cloudflare Pages 和 Telegraph。 [English](README-EN.md)|中文 -> [!WARNING] -> **The image upload feature is currently unavailable, but previously uploaded images can still be loaded normally.** -> -> **已知问题:图片上传功能目前无法使用,但已有图片仍然可以正常加载。需要了解具体原因请看下面的内容** - -> [!IMPORTANT] -> **Telegram has disabled the media upload functionality of Telegraph, which this project relies on. As a result, the image upload feature is no longer functional. We are currently working on a solution.** -> -> **Telegram 已禁用本项目所依赖的 Telegraph 的新媒体上传功能,因此目前新图片上传功能将无法继续使用,我们正在寻找解决方案。** - -> [!NOTE] -> 更多信息: -> For more details, please refer to the official statement: [Telegram Announcement](https://t.me/durov/343) -> -> ✂️ We’ve also disabled new media uploads to Telegraph, our standalone blogging tool, which seems to have been misused by anonymous actors. -> -> ✂️ 我们还禁用了独立博客工具 Telegraph 的新媒体上传功能,因为它似乎被匿名用户滥用了。 -> -> 相关issue: [#180](https://github.com/cf-pages/Telegraph-Image/issues/180) [#178](https://github.com/cf-pages/Telegraph-Image/issues/178) - ## 如何部署 diff --git a/functions/upload.js b/functions/upload.js index 154715408..4b4cfef4a 100644 --- a/functions/upload.js +++ b/functions/upload.js @@ -12,10 +12,18 @@ export async function onRequestPost(context) { // Contents of context object await errorHandling(context); telemetryData(context); const url = new URL(clonedRequest.url); - const response = fetch('https://telegra.ph/' + url.pathname + url.search, { + url.searchParams.append('source', 'bugtracker'); + const response = await fetch('https://telegra.ph/' + url.pathname + url.search, { method: clonedRequest.method, headers: clonedRequest.headers, body: clonedRequest.body, }); - return response; + const originalBody = await response.json(); + const wrappedBody = [originalBody]; + const modifiedResponse = new Response(JSON.stringify(wrappedBody), { + status: response.status, + statusText: response.statusText, + headers: response.headers + }); + return modifiedResponse; }