File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
fixtures/simple/app/app-redirect Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import { redirect } from 'next/navigation'
2+
3+ const Page = async ( ) => {
4+ return redirect ( `/app-redirect/dest` )
5+ }
6+
7+ export const generateStaticParams = async ( ) => {
8+ return [ { slug : 'prerendered' } ]
9+ }
10+
11+ export default Page
Original file line number Diff line number Diff line change 1+ export default function Page ( ) {
2+ return (
3+ < main >
4+ < h1 > Hello next/navigation#redirect target</ h1 >
5+ </ main >
6+ )
7+ }
8+
9+ export const dynamic = 'force-static'
Original file line number Diff line number Diff line change @@ -444,6 +444,20 @@ test.skipIf(hasDefaultTurbopackBuilds())<FixtureTestContext>(
444444 expect ( parsedBody . bundledCJSModule . isBundled ) . toEqual ( true )
445445 } ,
446446)
447+ for ( const { slug, label } of [
448+ { slug : 'prerendered' , label : 'prerendered' } ,
449+ { slug : 'non-prerendered' , label : 'not prerendered' } ,
450+ ] ) {
451+ test < FixtureTestContext > ( `app router page that uses next/navigation#redirect works when page is ${ label } ` , async ( ctx ) => {
452+ await createFixture ( 'simple' , ctx )
453+ await runPlugin ( ctx )
454+
455+ const response = await invokeFunction ( ctx , { url : `/app-redirect/${ slug } ` } )
456+
457+ expect ( response . statusCode ) . toBe ( 307 )
458+ expect ( response . headers [ 'location' ] ) . toBe ( '/app-redirect/dest' )
459+ } )
460+ }
447461
448462describe ( 'next patching' , async ( ) => {
449463 const { cp : originalCp , appendFile } = ( await vi . importActual (
You can’t perform that action at this time.
0 commit comments