@k3000/proxy
v0.6.1
Published
修复WebSocket转发,支持负载
Readme
轻量级的代理工具
修复WebSocket转发,支持负载
import {createProxy} from '@k3000/proxy'
createProxy({
/*map: {
'/target': 'http://domain/',
'domain2.com': 'http://domain3/',
'localhost:8080': 'http://domain4/',
'/': '/dir', // 代理有优先级,范围广的要放在下面
},*/
map: new class {
index = true
get '/api'() { // 支持负载
if (this.index) {
this.index = false
return 'http://domain1/'
} else {
this.index = true
return 'http://domain2/'
}
}
},
port: 80,
httpsOptions: {
key,
cert
},
preReq: (req, res) => false,
preRes: (req, res) => false,
})