MCPcopy
hub / github.com/weaigc/bingo / fetch

Function fetch

cloudflare/worker.js:4–27  ·  view source on GitHub ↗
(request, env = {})

Source from the content-addressed store, hash-verified

2
3const handlers = {
4 async fetch(request, env = {}) {
5 const uri = new URL(request.url)
6 console.log('uri', uri.toString())
7 if (uri.protocol === 'http:' && !/^[0-9.:]+$/.test(TARGET_HOST)) {
8 uri.protocol = 'https:';
9 }
10 uri.host = TARGET_HOST
11 uri.port = TARGET_HOST.split(':')[1] || ''
12 const headersObj = {}
13 for (const [key, value] of request.headers.entries()) {
14 if (key.startsWith('cf-') || key.startsWith('x-') || ['connection', 'origin', 'referer', 'host', 'authority', 'link'].includes(key)) continue
15 headersObj[key] = value
16 }
17 const headers = new Headers(headersObj)
18 headers.set('Host', uri.host)
19 // console.log(headers)
20 const response = await fetch(uri.toString(), {
21 headers,
22 method: request.method,
23 redirect: request.redirect,
24 body: request.body,
25 })
26 return response
27 },
28}
29
30export default handlers

Callers 13

CommunityPromptsFunction · 0.85
handlerFunction · 0.85
handlerFunction · 0.85
handlerFunction · 0.85
handlerFunction · 0.85
GETFunction · 0.85
createConversationMethod · 0.85
sydneyProxyMethod · 0.85
createImageMethod · 0.85
uploadImageMethod · 0.85
createImageFunction · 0.85
fetchProxyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected