Unverified Commit faf4a0ab authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure getStaticProps isn't called without params with i18n (#18702)

This corrects additional fallback pages being generated without the fallback flag causing `getStaticProps` to be called without params with i18n. The revalidation aspect of the issue has been corrected separately in https://github.com/vercel/next.js/pull/18569

Fixes: https://github.com/vercel/next.js/issues/18404
parent 4e7835c9
...@@ -808,7 +808,7 @@ export default async function build( ...@@ -808,7 +808,7 @@ export default async function build(
} }
} }
if (isSsg && !isFallback) { if (isSsg) {
// remove non-locale prefixed variant from defaultMap // remove non-locale prefixed variant from defaultMap
delete defaultMap[page] delete defaultMap[page]
} }
......
...@@ -24,6 +24,11 @@ export default function Page(props) { ...@@ -24,6 +24,11 @@ export default function Page(props) {
} }
export const getStaticProps = ({ params, locale, locales, defaultLocale }) => { export const getStaticProps = ({ params, locale, locales, defaultLocale }) => {
// ensure getStaticProps isn't called without params
if (!params || !params.slug) {
throw new Error(`missing params ${JSON.stringify(params)}`)
}
return { return {
props: { props: {
params, params,
......
...@@ -24,6 +24,11 @@ export default function Page(props) { ...@@ -24,6 +24,11 @@ export default function Page(props) {
} }
export const getStaticProps = ({ params, locale, locales, defaultLocale }) => { export const getStaticProps = ({ params, locale, locales, defaultLocale }) => {
// ensure getStaticProps isn't called without params
if (!params || !params.slug) {
throw new Error(`missing params ${JSON.stringify(params)}`)
}
return { return {
props: { props: {
params, params,
......
...@@ -22,6 +22,11 @@ export default function Page(props) { ...@@ -22,6 +22,11 @@ export default function Page(props) {
} }
export const getStaticProps = ({ params, locale, locales }) => { export const getStaticProps = ({ params, locale, locales }) => {
// ensure getStaticProps isn't called without params
if (!params || !params.slug) {
throw new Error(`missing params ${JSON.stringify(params)}`)
}
if (locale === 'en' || locale === 'nl') { if (locale === 'en' || locale === 'nl') {
return { return {
notFound: true, notFound: true,
......
...@@ -24,6 +24,11 @@ export default function Page(props) { ...@@ -24,6 +24,11 @@ export default function Page(props) {
} }
export const getStaticProps = ({ params, locale, locales }) => { export const getStaticProps = ({ params, locale, locales }) => {
// ensure getStaticProps isn't called without params
if (!params || !params.slug) {
throw new Error(`missing params ${JSON.stringify(params)}`)
}
if (locale === 'en' || locale === 'nl') { if (locale === 'en' || locale === 'nl') {
return { return {
notFound: true, notFound: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment