Xiang (@xjfkkk) 在 cloudflare反代TG 中发帖
适用于无法请求TG消息的情况
worker
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
// 确保请求方法是 POST
if (request.method !== 'POST') {
return new Response('Only POST requests are allowed', { status: 405 })
}
// 从请求 URL 中提取 bot token 和方法
const url = new URL(request.url)
const pathParts = url.pathname.split('/')
...