1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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

This commit is contained in:
Arunoda Susiripala 2017-05-23 23:00:14 +05:30 committed by Guillermo Rauch
parent d36118ab02
commit 3c95f21d8c

View file

@ -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 {
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')
}
} }