草木志
已识乾坤大,犹怜草木青
请留下你的名字
昵称仅用于区分你的记录可在底部设置中修改
遇见一株草木
点此上传花草照片支持相机直接拍摄
正在辨识·请稍候
花鸟册
册中尚无记录去识一朵花吧
Cloudflare Worker 代码
复制以下代码,粘贴到 Cloudflare Worker 编辑器中,点 Deploy 即可。
export default { async fetch(request, env) { if (request.method === 'OPTIONS') { return new Response(null, { headers: corsHeaders() }); } const url = new URL(request.url); const target = 'https://dashscope-intl.aliyuncs.com/compatible-mode' + url.pathname; const body = await request.text(); const headers = { 'Content-Type': 'application/json' }; const auth = request.headers.get('Authorization'); if (auth) headers['Authorization'] = auth; const resp = await fetch(target, { method: request.method, headers, body }); const data = await resp.text(); return new Response(data, { status: resp.status, headers: { ...corsHeaders(), 'Content-Type': 'application/json' } }); } }; function corsHeaders() { return { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', 'Access-Control-Allow-Headers': 'Content-Type, Authorization', }; }