diff --git a/packages/next/src/client/components/http-access-fallback/http-access-fallback.ts b/packages/next/src/client/components/http-access-fallback/http-access-fallback.ts index 3083c3b235c4a..87b8366cab1f0 100644 --- a/packages/next/src/client/components/http-access-fallback/http-access-fallback.ts +++ b/packages/next/src/client/components/http-access-fallback/http-access-fallback.ts @@ -47,9 +47,12 @@ export function getAccessFallbackHTTPStatus( export function getAccessFallbackErrorTypeByStatus( status: number -): 'not-found' | undefined { - // TODO: support 403 and 401 +): 'not-found' | 'forbidden' | 'unauthorized' | undefined { switch (status) { + case 401: + return 'unauthorized' + case 403: + return 'forbidden' case 404: return 'not-found' default: diff --git a/packages/next/src/lib/metadata/resolve-metadata.ts b/packages/next/src/lib/metadata/resolve-metadata.ts index 9c7534b73ec84..84f4184c47053 100644 --- a/packages/next/src/lib/metadata/resolve-metadata.ts +++ b/packages/next/src/lib/metadata/resolve-metadata.ts @@ -67,7 +67,7 @@ type ViewportResolver = ( parent: ResolvingViewport ) => Viewport | Promise -export type MetadataErrorType = 'not-found' +export type MetadataErrorType = 'not-found' | 'forbidden' | 'unauthorized' export type MetadataItems = [ Metadata | MetadataResolver | null, diff --git a/packages/next/src/server/lib/app-dir-module.ts b/packages/next/src/server/lib/app-dir-module.ts index 3e2438ed074a5..3e5bc9dfcf582 100644 --- a/packages/next/src/server/lib/app-dir-module.ts +++ b/packages/next/src/server/lib/app-dir-module.ts @@ -40,7 +40,7 @@ export async function getLayoutOrPageModule(loaderTree: LoaderTree) { export async function getComponentTypeModule( loaderTree: LoaderTree, - moduleType: 'layout' | 'not-found' + moduleType: 'layout' | 'not-found' | 'forbidden' | 'unauthorized' ) { const { [moduleType]: module } = loaderTree[2] if (typeof module !== 'undefined') {