Skip to content

Commit

Permalink
Secret feature fix
Browse files Browse the repository at this point in the history
  • Loading branch information
issacnitinmsft authored Jan 3, 2022
1 parent cbf9e56 commit d2fe913
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ var server = http.createServer(function (req, res) {
var reqUrl = req.url.replace(/^\/+|\/+$/g, '');
var method = req.method.toLowerCase();

if(!reqUrl || (!!reqUrl && (reqUrl == "" || reqUrl.toLowerCase() == "index.html"))){
if(config.enableSecretsFeature) {
console.log(req.headers['x-secret']);
console.log(process.env.HEADER_VALUE);
if(req.headers['x-secret'] != process.env.HEADER_VALUE) {
res.writeHead(401, "Unauthorized");
res.end();
return;
}
if(config.enableSecretsFeature) {
console.log(req.headers['x-secret']);
console.log(process.env.HEADER_VALUE);
if(req.headers['x-secret'] != process.env.HEADER_VALUE) {
res.writeHead(401, "Unauthorized");
res.end();
return;
}
}
if(!reqUrl || (!!reqUrl && (reqUrl == "" || reqUrl.toLowerCase() == "index.html"))){
var data = fs.readFileSync('index.html');

dbOperations.queryCount(function (visitCount){
Expand Down Expand Up @@ -109,4 +109,4 @@ exports.close = function (callback) {
server.close(callback);
};

server.listen(port);
server.listen(port);

0 comments on commit d2fe913

Please sign in to comment.