Skip to content

Instantly share code, notes, and snippets.

@tubackkhoa
Created January 6, 2025 03:21
Show Gist options
  • Save tubackkhoa/1090758241e3fc22f0e78397213941a1 to your computer and use it in GitHub Desktop.
Save tubackkhoa/1090758241e3fc22f0e78397213941a1 to your computer and use it in GitHub Desktop.
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