Fix crash when file does not exist... and 404 page contents don't exist :)

This commit is contained in:
Bryan Ashby 2017-02-16 21:09:53 -07:00
parent 6285193545
commit 6a684266a2
1 changed files with 2 additions and 1 deletions

View File

@ -160,10 +160,11 @@ exports.getModule = class WebServerModule extends ServerModule {
routeStaticFile(req, resp) { routeStaticFile(req, resp) {
const fileName = req.url.substr(req.url.indexOf('/', 1)); const fileName = req.url.substr(req.url.indexOf('/', 1));
const filePath = paths.join(Config.contentServers.web.staticRoot, fileName); const filePath = paths.join(Config.contentServers.web.staticRoot, fileName);
const self = this;
fs.stat(filePath, (err, stats) => { fs.stat(filePath, (err, stats) => {
if(err) { if(err) {
return this.respondWithError(resp, 404, 'File not found.', 'File Not Found'); return self.respondWithError(resp, 404, 'File not found.', 'File Not Found');
} }
const headers = { const headers = {