未验证 提交 34059439 编写于 作者: J JJ Kasper 提交者: GitHub

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

上级 4eb7dde4
......@@ -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' ||
......
......@@ -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'
......
......@@ -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/)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册