Created
January 6, 2025 03:21
-
-
Save tubackkhoa/1090758241e3fc22f0e78397213941a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import http from 'http'; | |
| import httpProxy from 'http-proxy'; | |
| const items = Object.values({ | |
| 'jup.ag': 'https://jupiter-frontend.rpcpool.com', | |
| 'pump.fun': | |
| 'https://pump-fe.helius-rpc.com/?api-key=1b8db865-a5a1-4535-9aec-01061440523b', | |
| 'raydium.io': 'https://raydium-raydium-5ad5.mainnet.rpcpool.com', | |
| }); | |
| let currentInd = 0; | |
| const nextItem = () => { | |
| if (currentInd >= items.length) { | |
| currentInd = 0; | |
| } | |
| return items[currentInd++]; | |
| }; | |
| const proxy = httpProxy.createProxyServer({}); | |
| const proxyServer = http.createServer(function (req, res) { | |
| const [origin, target] = nextItem(); | |
| req.headers['origin'] = `https://${origin}`; | |
| proxy.web(req, res, { | |
| secure: false, | |
| target, | |
| xfwd: true, | |
| ws: true, | |
| changeOrigin: true, | |
| }); | |
| }); | |
| proxyServer.listen(8000, () => { | |
| console.log('server started at 8000'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment