Make sure to 404 for /_next/static (#8564)

This commit is contained in:
JJ Kasper 2019-08-29 15:00:54 -05:00 committed by GitHub
parent 4eb7dde490
commit 340594398e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View file

@ -208,6 +208,10 @@ export default class Server {
// The commons folder holds commonschunk files
// The chunks folder holds dynamic entries
// The buildId folder holds pages and potentially other assets. As buildId changes per build it can be long-term cached.
// make sure to 404 for /_next/static itself
if (!params.path) return this.render404(req, res, parsedUrl)
if (
params.path[0] === CLIENT_STATIC_FILES_RUNTIME ||
params.path[0] === 'chunks' ||

View file

@ -80,6 +80,11 @@ describe('Production Usage', () => {
expect(res.status).toBe(404)
})
it('should render 404 for /_next/static route', async () => {
const html = await renderViaHTTP(appPort, '/_next/static')
expect(html).toMatch(/This page could not be found/)
})
it('should render 200 for POST on page', async () => {
const res = await fetch(`http://localhost:${appPort}/about`, {
method: 'POST'

View file

@ -52,6 +52,11 @@ describe('Serverless', () => {
expect(html).toMatch(/This page could not be found/)
})
it('should render 404 for /_next/static', async () => {
const html = await renderViaHTTP(appPort, '/_next/static')
expect(html).toMatch(/This page could not be found/)
})
it('should render an AMP page', async () => {
const html = await renderViaHTTP(appPort, '/some-amp?amp=1')
expect(html).toMatch(/Hi Im an AMP page/)