Skip to content

Commit

Permalink
update metadata error convention (#72834)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Nov 15, 2024
1 parent 4d8260d commit e5ec2de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/lib/metadata/resolve-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type ViewportResolver = (
parent: ResolvingViewport
) => Viewport | Promise<Viewport>

export type MetadataErrorType = 'not-found'
export type MetadataErrorType = 'not-found' | 'forbidden' | 'unauthorized'

export type MetadataItems = [
Metadata | MetadataResolver | null,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/lib/app-dir-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit e5ec2de

Please sign in to comment.