Changed some settings in cors-anywhere

This commit is contained in:
Kasper Rynning-Tønnesen
2015-07-20 16:39:07 +02:00
parent da56e503f0
commit dff5f9dc7a
274 changed files with 26 additions and 39297 deletions

View File

@@ -226,6 +226,12 @@ var getHandler = exports.getHandler = function(options, proxy) {
};
return function(req, res) {
if(req.headers.referer && req.headers.referer.substring(0,15) !== "https://zoff.no")
{
res.writeHead(401, "You're accessing the cors-anywhere from wrong domain, only https://zoff.no is allowed");
res.end();
return;
}
var cors_headers = withCORS({}, req);
if (req.method == 'OPTIONS') {
// Pre-flight request. Reply successfully:
@@ -238,16 +244,8 @@ var getHandler = exports.getHandler = function(options, proxy) {
if (!location) {
// Invalid API call. Show how to correctly use the API
showUsage(cors_headers, res);
return;
}
if (location.host === 'iscorsneeded') {
// Is CORS needed? This path is provided so that API consumers can test whether it's necessary
// to use CORS. The server's reply is always No, because if they can read it, then CORS headers
// are not necessary.
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('no');
res.writeHead(302, {'Location': 'http://'+req.headers.host.split(":")[0]});
res.end('Wrong port');
return;
}