@@ -624,7 +624,7 @@ export async function renderToHTML(
624624 ( key ) =>
625625 key !== 'revalidate' &&
626626 key !== 'props' &&
627- key !== 'unstable_redirect ' &&
627+ key !== 'redirect ' &&
628628 key !== 'unstable_notFound'
629629 )
630630
@@ -649,11 +649,11 @@ export async function renderToHTML(
649649 }
650650
651651 if (
652- 'unstable_redirect ' in data &&
653- data . unstable_redirect &&
654- typeof data . unstable_redirect === 'object'
652+ 'redirect ' in data &&
653+ data . redirect &&
654+ typeof data . redirect === 'object'
655655 ) {
656- checkRedirectValues ( data . unstable_redirect , req )
656+ checkRedirectValues ( data . redirect , req )
657657
658658 if ( isBuildTimeSSG ) {
659659 throw new Error (
@@ -664,10 +664,10 @@ export async function renderToHTML(
664664
665665 if ( isDataReq ) {
666666 ; ( data as any ) . props = {
667- __N_REDIRECT : data . unstable_redirect . destination ,
667+ __N_REDIRECT : data . redirect . destination ,
668668 }
669669 } else {
670- handleRedirect ( res , data . unstable_redirect )
670+ handleRedirect ( res , data . redirect )
671671 return null
672672 }
673673 }
@@ -760,11 +760,15 @@ export async function renderToHTML(
760760
761761 const invalidKeys = Object . keys ( data ) . filter (
762762 ( key ) =>
763- key !== 'props' &&
764- key !== 'unstable_redirect' &&
765- key !== 'unstable_notFound'
763+ key !== 'props' && key !== 'redirect' && key !== 'unstable_notFound'
766764 )
767765
766+ if ( ( data as any ) . unstable_redirect ) {
767+ throw new Error (
768+ `unstable_redirect has been renamed to redirect, please update the field to continue. Page: ${ pathname } `
769+ )
770+ }
771+
768772 if ( invalidKeys . length ) {
769773 throw new Error ( invalidKeysMsg ( 'getServerSideProps' , invalidKeys ) )
770774 }
@@ -780,18 +784,15 @@ export async function renderToHTML(
780784 return null
781785 }
782786
783- if (
784- 'unstable_redirect' in data &&
785- typeof data . unstable_redirect === 'object'
786- ) {
787- checkRedirectValues ( data . unstable_redirect , req )
787+ if ( 'redirect' in data && typeof data . redirect === 'object' ) {
788+ checkRedirectValues ( data . redirect , req )
788789
789790 if ( isDataReq ) {
790791 ; ( data as any ) . props = {
791- __N_REDIRECT : data . unstable_redirect . destination ,
792+ __N_REDIRECT : data . redirect . destination ,
792793 }
793794 } else {
794- handleRedirect ( res , data . unstable_redirect )
795+ handleRedirect ( res , data . redirect )
795796 return null
796797 }
797798 }
0 commit comments