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:
parent
d36118ab02
commit
3c95f21d8c
|
@ -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')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue