Tuesday 23 May 2017

Run Cors-Anywhere Server With SSL

I've got Cors-Anywhere running fine on my own private server through normal HTTP. However, I would like it to allow HTTPS requests. In the server.js file I have:

//HTTPS Setup
var fs = require("fs")
// Listen on a specific host via the HOST environment variable
var host = process.env.HOST || '0.0.0.0';
// Listen on a specific port via the PORT environment variable
var port = process.env.PORT || 8080;

var cors_proxy = require('cors-anywhere');
cors_proxy.createServer({
    key: fs.readFileSync('privatekey.pem').toString(),
    cert: fs.readFileSync('certificate.pem').toString(),
    originWhitelist: [], // Allow all origins
    requireHeader: ['origin', 'x-requested-with'],
    removeHeaders: ['cookie', 'cookie2']
}).listen(port, host, function() {
    console.log('Running CORS Anywhere on ' + host + ':' + port);
});

I am able to run the script without any errors, however, when I point my browser to the HTTPS version, I receive a Chrome error of "https://myurl.site.com:8080 unexpectedly closed the connection."

Any ideas of what I am doing wrong? Thanks a lot!



via M2com

No comments:

Post a Comment