Skip to content

Instantly share code, notes, and snippets.

@StrongerMyself
Created August 21, 2019 09:40
Show Gist options
  • Save StrongerMyself/8a90ebe893d5dd9406aad9e6971cc6c2 to your computer and use it in GitHub Desktop.
Save StrongerMyself/8a90ebe893d5dd9406aad9e6971cc6c2 to your computer and use it in GitHub Desktop.
const http = require('http');
const httpProxy = require('http-proxy');
const options = {
changeOrigin: true,
protocol: 'https',
target: 'https://yobit.net',
host: 'yobit.net',
};
const proxy = httpProxy.createProxyServer(options); // See (†)
proxy.on('error', function(e) {
console.log(e);
});
proxy.on('proxyRes', function(proxyRes, req, res) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS');
});
http.createServer(function(req, res) {
proxy.web(req, res);
}).listen(8005);
console.log('server listening 8005');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment