-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix noindex is missing on static not-found page (#67135)
Render noindex into a flight data and rsc payload when page path is `/404` When it's static generation, noindex is not rendered due to the statusCode from mock request is 200, but we can relying on the pagePath as `/404` page should always contain `nonidex` We were missing the noindex before for flight generation, now we'll render it when it's 404 page.
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <h1>Foo</h1> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
const isPPREnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' | ||
|
||
describe('app dir - not-found - default', () => { | ||
const { next, isNextStart } = nextTestSetup({ | ||
files: __dirname, | ||
skipDeployment: true, | ||
}) | ||
|
||
it('should has noindex in the head html', async () => { | ||
const $ = await next.render$('/does-not-exist') | ||
expect(await $('meta[name="robots"]').attr('content')).toBe('noindex') | ||
}) | ||
|
||
if (isNextStart) { | ||
it('should contain noindex contain in the page', async () => { | ||
const html = await next.readFile('.next/server/app/_not-found.html') | ||
const rsc = await next.readFile( | ||
`.next/server/app/_not-found.${isPPREnabled ? 'prefetch.' : ''}rsc` | ||
) | ||
|
||
expect(html).toContain('noindex') | ||
expect(rsc).toContain('noindex') | ||
}) | ||
} | ||
}) |