Created
August 21, 2019 09:40
-
-
Save StrongerMyself/8a90ebe893d5dd9406aad9e6971cc6c2 to your computer and use it in GitHub Desktop.
This file contains 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
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