Files

1 line
4.0 KiB
JSON

{"repo": "chemark/agi-devourer", "files": {"proxy.js": {"ff99e9b4b7a68c76b897e44282e9823da868a42d": {"t": 1785745998.4442902, "n": 1798, "h": "ae8bfbc232ce2569", "c": "const http = require('http');\nconst https = require('https');\n\nconst PROXY_PORT = 3001;\nconst TARGET_HOST = 'api.deepseek.com';\n\nconst server = http.createServer((req, res) => {\n // CORS headers - allow all\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');\n\n if (req.method === 'OPTIONS') {\n res.writeHead(204);\n res.end();\n return;\n }\n\n if (req.method !== 'POST') {\n res.writeHead(405);\n res.end('Method Not Allowed');\n return;\n }\n\n let body = '';\n req.on('data', chunk => body += chunk);\n req.on('end', () => {\n const options = {\n hostname: TARGET_HOST,\n port: 443,\n path: req.url,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': req.headers['authorization'] || '',\n 'Content-Length': Buffer.byteLength(body)\n }\n };\n\n const proxyReq = https.request(options, (proxyRes) => {\n res.writeHead(proxyRes.statusCode, {\n 'Content-Type': 'application/json',\n 'Access-Control-Allow-Origin': '*'\n });\n proxyRes.pipe(res);\n });\n\n proxyReq.on('error', (e) => {\n console.error('Proxy error:', e);\n res.writeHead(502);\n res.end(JSON.stringify({ error: e.message }));\n });\n\n proxyReq.write(body);\n proxyReq.end();\n });\n});\n\nserver.listen(PROXY_PORT, () => {\n console.log(`✅ CORS 代理已启动 → http://localhost:${PROXY_PORT}`);\n console.log(` 浏览器 → localhost:3001 → ${TARGET_HOST}`);\n});\n"}, "055fb6360ec1fb72f0cb4a7da8af5a839ffdefe3": {"t": 1785758648.9133234, "n": 1798, "h": "ae8bfbc232ce2569", "c": "const http = require('http');\nconst https = require('https');\n\nconst PROXY_PORT = 3001;\nconst TARGET_HOST = 'api.deepseek.com';\n\nconst server = http.createServer((req, res) => {\n // CORS headers - allow all\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');\n\n if (req.method === 'OPTIONS') {\n res.writeHead(204);\n res.end();\n return;\n }\n\n if (req.method !== 'POST') {\n res.writeHead(405);\n res.end('Method Not Allowed');\n return;\n }\n\n let body = '';\n req.on('data', chunk => body += chunk);\n req.on('end', () => {\n const options = {\n hostname: TARGET_HOST,\n port: 443,\n path: req.url,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': req.headers['authorization'] || '',\n 'Content-Length': Buffer.byteLength(body)\n }\n };\n\n const proxyReq = https.request(options, (proxyRes) => {\n res.writeHead(proxyRes.statusCode, {\n 'Content-Type': 'application/json',\n 'Access-Control-Allow-Origin': '*'\n });\n proxyRes.pipe(res);\n });\n\n proxyReq.on('error', (e) => {\n console.error('Proxy error:', e);\n res.writeHead(502);\n res.end(JSON.stringify({ error: e.message }));\n });\n\n proxyReq.write(body);\n proxyReq.end();\n });\n});\n\nserver.listen(PROXY_PORT, () => {\n console.log(`✅ CORS 代理已启动 → http://localhost:${PROXY_PORT}`);\n console.log(` 浏览器 → localhost:3001 → ${TARGET_HOST}`);\n});\n"}}}}