Created
December 7, 2018 12:40
-
-
Save bhupendra-nitt/e521bca0c3c16e2fc1f2c9f094a9a57b 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
var express = require('express'); | |
var request = require('request'); | |
var bodyParser = require('body-parser') | |
var app = express(); | |
app.use(bodyParser.raw()) | |
app.use('*', function(req, res) { | |
console.log(req.baseUrl) | |
req.headers['host'] = 'HOST_URL_TO_PROXY' | |
req.headers["Access-Control-Allow-Origin"] = "*" | |
req.headers['Accept-Encoding'] = 'gzip, deflate, br' | |
res.header("Access-Control-Allow-Origin", "*"); | |
var url = 'HOST_URL' + req.baseUrl; | |
req.pipe(request(url, function (error, response, body) { | |
console.log('error:', error); // Print the error if one occurred | |
console.log('statusCode:', response && response.statusCode); | |
})).pipe(res); | |
}); | |
app.listen(4400); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment