mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Handle 404 thrown from send (#5779)
This commit is contained in:
parent
4322bb13dd
commit
633dd87b18
|
@ -231,7 +231,7 @@ export default class Server {
|
|||
try {
|
||||
return await serveStatic(req, res, path)
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
if (err.code === 'ENOENT' || err.statusCode === 404) {
|
||||
this.render404(req, res)
|
||||
} else {
|
||||
throw err
|
||||
|
|
|
@ -61,6 +61,12 @@ describe('Production Usage', () => {
|
|||
expect(res.status).toBe(404)
|
||||
})
|
||||
|
||||
it('should render 404 for dotfiles in /static', async () => {
|
||||
const url = `http://localhost:${appPort}/static/.env`
|
||||
const res = await fetch(url)
|
||||
expect(res.status).toBe(404)
|
||||
})
|
||||
|
||||
it('should render 501 if the HTTP method is not GET or HEAD', async () => {
|
||||
const url = `http://localhost:${appPort}/_next/abcdef`
|
||||
const methods = ['POST', 'PUT', 'DELETE']
|
||||
|
|
Loading…
Reference in a new issue