const express = require('express'); | |
const proxy = require('express-http-proxy'); | |
const app = express(); | |
const targetUrl = 'https://www.bing.com'; | |
const port = 7860; | |
const baseUrl = 'bing'; | |
app.use('/', proxy(targetUrl, { | |
https: true, | |
proxyReqOptDecorator: (proxyReqOpts, srcReq) => { | |
//console.log(srcReq); | |
// Modify the request headers if necessary | |
proxyReqOpts.headers['x-forwarded-for'] = ''; | |
return proxyReqOpts; | |
}, | |
})); | |
app.listen(port, () => { | |
console.log(`Reverse proxy server running on ${baseUrl}`); | |
}); |