mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Changed some settings in cors-anywhere
This commit is contained in:
18
server/node_modules/cors-anywhere/lib/cors-anywhere.js
generated
vendored
18
server/node_modules/cors-anywhere/lib/cors-anywhere.js
generated
vendored
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user