Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit c47c802

Browse files
committed
Fix error handling for custom settings pages
1 parent 12ac3d2 commit c47c802

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

api/wordpress/_global/getPostTypeStaticProps.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,22 @@ export default async function getPostTypeStaticProps(
8080

8181
/* -- Handle pages set via Additional Settings. -- */
8282
if (Object.keys(customPageQuery).includes(slug)) {
83-
const {apolloClient, error, ...pageData} = await getSettingsCustomPage(slug)
83+
const {apolloClient, ...pageData} = await getSettingsCustomPage(slug)
84+
85+
// Display 404 error page if error encountered.
86+
if (pageData.error && '404' !== slug) {
87+
return {
88+
notFound: true
89+
}
90+
}
91+
92+
// Remove error prop.
93+
delete pageData?.error
8494

8595
return addApolloState(apolloClient, {
8696
props: {
8797
...pageData,
88-
...sharedProps,
89-
error
98+
...sharedProps
9099
},
91100
revalidate
92101
})

0 commit comments

Comments
 (0)