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 hoxy = require('hoxy'); | |
var port = 8000; | |
var proxy = hoxy.createServer().listen(port, function() { | |
console.log('The proxy is listening on port ' + port + '.'); | |
}); | |
proxy.intercept('response', function(req, resp, cycle) { | |
if(req.method=="OPTIONS"){ | |
resp.statusCode=200; | |
var headers = resp.headers; | |
// IE8 does not allow domains to be specified, just the * | |
// headers["Access-Control-Allow-Origin"] = req.headers.origin; | |
headers["access-control-allow-origin"] = "*"; | |
headers["access-control-allow-methods"] = "POST, GET, PUT, DELETE, OPTIONS"; | |
headers["allow"] = "POST, GET, PUT, DELETE, OPTIONS"; | |
headers["access-control-allow-credentials"] = true; | |
headers["access-control-max-age"] = '86400'; // 24 hours | |
headers["access-control-allow-headers"] = "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept,If-Modified-Since,Pragma,Cache-Control"; | |
delete headers.location | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment