From 3c95f21d8c48a8aa2cfac3c93c715830db35ce9d Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Tue, 23 May 2017 23:00:14 +0530 Subject: [PATCH] Do not try to server unnessesary files in either dev or prod. (#2048) --- server/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/index.js b/server/index.js index 687091f7..9c703989 100644 --- a/server/index.js +++ b/server/index.js @@ -100,24 +100,32 @@ export default class Server { }, '/_next/:hash/manifest.js': async (req, res, params) => { + if (!this.dev) return this.send404(res) + this.handleBuildHash('manifest.js', params.hash, res) const p = join(this.dir, `${this.dist}/manifest.js`) await this.serveStatic(req, res, p) }, '/_next/:hash/main.js': async (req, res, params) => { + if (!this.dev) return this.send404(res) + this.handleBuildHash('main.js', params.hash, res) const p = join(this.dir, `${this.dist}/main.js`) await this.serveStatic(req, res, p) }, '/_next/:hash/commons.js': async (req, res, params) => { + if (!this.dev) return this.send404(res) + this.handleBuildHash('commons.js', params.hash, res) const p = join(this.dir, `${this.dist}/commons.js`) await this.serveStatic(req, res, p) }, '/_next/:hash/app.js': async (req, res, params) => { + if (this.dev) return this.send404(res) + this.handleBuildHash('app.js', params.hash, res) const p = join(this.dir, `${this.dist}/app.js`) await this.serveStatic(req, res, p) @@ -341,4 +349,9 @@ export default class Server { res.setHeader('Cache-Control', 'max-age=365000000, immutable') } + + send404 (res) { + res.statusCode = 404 + res.end('404 - Not Found') + } }