From ec91c40b81c2d3f7a99eecabf4445e6bfa17444b Mon Sep 17 00:00:00 2001 From: jrtechs Date: Wed, 8 Aug 2018 19:52:17 -0400 Subject: [PATCH] Fixed the server from not serving txt files for sitemap.txt and robots.txt --- includes/includes.js | 11 ++++++----- server.js | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/includes.js b/includes/includes.js index 9bcc7e0..77d2347 100644 --- a/includes/includes.js +++ b/includes/includes.js @@ -55,9 +55,7 @@ module.exports = */ sendCSS: function(result, path, cache) { - - - var css = cache.get(path); + const css = cache.get(path); if(css == null) { @@ -77,8 +75,11 @@ module.exports = } else { - var eTag = crypto.createHash('md5').update(css).digest('hex'); - result.writeHead(200, {'Content-Type': 'text/css', 'Cache-Control': 'public, max-age=2678400', 'ETag': '"' + eTag + '"', 'Vary': 'Accept-Encoding'}); + const eTag = crypto.createHash('md5').update(css).digest('hex'); + result.writeHead(200, {'Content-Type': 'text/css', + 'Cache-Control': 'public, max-age=2678400', + 'ETag': '"' + eTag + '"', + 'Vary': 'Accept-Encoding'}); result.write(css); result.end(); } diff --git a/server.js b/server.js index 60381f2..2ec0eeb 100644 --- a/server.js +++ b/server.js @@ -27,7 +27,7 @@ const app = express(); //compresses the site -var compression = require('compression') +const compression = require('compression') app.use(compression()); const port = 8000; @@ -50,7 +50,7 @@ app.use(function(request, res) { require("./img/image.js").main(res, filename, cache); } - else if(filename.includes("/css/") || filename.includes(".woff2")) + else if(filename.includes("/css/") || filename.includes(".woff2") || filename.includes(".txt")) { includes.sendCSS(res, filename, cache) }