Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix notFound status code with ISR in app (#55542)
This ensures we properly set/restore the status code with ISR paths in app router so that when we set the 404 status code with `notFound` it is persisted properly. Fixes: #43831 Closes: #48342 x-ref: #49387 (comment)
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 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
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,29 @@ | ||
import { notFound } from 'next/navigation' | ||
|
||
export interface Props { | ||
params: { | ||
slug: string | ||
} | ||
} | ||
|
||
const Article = ({ params }: Props) => { | ||
const { slug } = params | ||
|
||
if (slug !== 'works') { | ||
return notFound() | ||
} | ||
return <div>Articles page with slug</div> | ||
} | ||
|
||
export const revalidate = 1 | ||
export const dynamicParams = true | ||
|
||
export async function generateStaticParams() { | ||
return [ | ||
{ | ||
slug: 'works', // Anything not this should be a 404 with no ISR | ||
}, | ||
] | ||
} | ||
|
||
export default Article |