Commit 3c95f21d authored by Arunoda Susiripala's avatar Arunoda Susiripala Committed by Guillermo Rauch

Do not try to server unnessesary files in either dev or prod. (#2048)

parent d36118ab
...@@ -100,24 +100,32 @@ export default class Server { ...@@ -100,24 +100,32 @@ export default class Server {
}, },
'/_next/:hash/manifest.js': async (req, res, params) => { '/_next/:hash/manifest.js': async (req, res, params) => {
if (!this.dev) return this.send404(res)
this.handleBuildHash('manifest.js', params.hash, res) this.handleBuildHash('manifest.js', params.hash, res)
const p = join(this.dir, `${this.dist}/manifest.js`) const p = join(this.dir, `${this.dist}/manifest.js`)
await this.serveStatic(req, res, p) await this.serveStatic(req, res, p)
}, },
'/_next/:hash/main.js': async (req, res, params) => { '/_next/:hash/main.js': async (req, res, params) => {
if (!this.dev) return this.send404(res)
this.handleBuildHash('main.js', params.hash, res) this.handleBuildHash('main.js', params.hash, res)
const p = join(this.dir, `${this.dist}/main.js`) const p = join(this.dir, `${this.dist}/main.js`)
await this.serveStatic(req, res, p) await this.serveStatic(req, res, p)
}, },
'/_next/:hash/commons.js': async (req, res, params) => { '/_next/:hash/commons.js': async (req, res, params) => {
if (!this.dev) return this.send404(res)
this.handleBuildHash('commons.js', params.hash, res) this.handleBuildHash('commons.js', params.hash, res)
const p = join(this.dir, `${this.dist}/commons.js`) const p = join(this.dir, `${this.dist}/commons.js`)
await this.serveStatic(req, res, p) await this.serveStatic(req, res, p)
}, },
'/_next/:hash/app.js': async (req, res, params) => { '/_next/:hash/app.js': async (req, res, params) => {
if (this.dev) return this.send404(res)
this.handleBuildHash('app.js', params.hash, res) this.handleBuildHash('app.js', params.hash, res)
const p = join(this.dir, `${this.dist}/app.js`) const p = join(this.dir, `${this.dist}/app.js`)
await this.serveStatic(req, res, p) await this.serveStatic(req, res, p)
...@@ -341,4 +349,9 @@ export default class Server { ...@@ -341,4 +349,9 @@ export default class Server {
res.setHeader('Cache-Control', 'max-age=365000000, immutable') res.setHeader('Cache-Control', 'max-age=365000000, immutable')
} }
send404 (res) {
res.statusCode = 404
res.end('404 - Not Found')
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment