Skip to content

Commit

Permalink
feat: add http proxy supports
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Jun 13, 2024
1 parent 7e67c39 commit 23c38f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"lodash-es": "^4.17.21",
"log-update": "^6.0.0",
"luxon": "^3.4.4",
"node-fetch-native": "^1.6.4",
"util-ex": "2.0.0-alpha.18"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions src/lib/global-fetch-proxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createProxy } from "node-fetch-native/proxy";

const fetch = globalThis.fetch
globalThis.fetch = function (input: RequestInfo | URL, init?: RequestInit | undefined) {
if (!init) {init = {}}
init = {...createProxy(), ...init}
return fetch(input, init)
}
1 change: 1 addition & 0 deletions src/lib/init-tools.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './global-fetch-proxy.js'
import {
event, // event bus for server
backendEventable,
Expand Down

0 comments on commit 23c38f7

Please sign in to comment.