Created
August 11, 2016 18:53
-
-
Save weisjohn/3f696e6709c5edc33f7ed180bc84c4e0 to your computer and use it in GitHub Desktop.
Revisions
-
weisjohn created this gist
Aug 11, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ const http = require('http'); const https = require('https'); const server = http.createServer(); const host = 'example.com'; server.on('request', (req, res) => { // set cors on the response res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Accept-Language'); // manipulate the headers for SSL req.headers.host = host; // form the options var options = { hostname: host, port: 443, path: req.url, method: req.method, headers: req.headers, }; var request = https.request(options, (response) => { res.writeHead(response.statusCode, response.headers); response.on('data', (d) => { res.write(d); }); response.on('end', (d) => { res.end(); }); }); request.on('error', (e) => { console.error(e); }); request.end(); }); server.listen(4000);