Skip to content

Commit

Permalink
fix: Add error handling in case an invalid i18n request config file h…
Browse files Browse the repository at this point in the history
…as been specified (#1327)
  • Loading branch information
amannn authored Sep 5, 2024
1 parent 7c3a6a1 commit 18b9fd6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/next-intl/src/server/react-server/getConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ async function receiveRuntimeConfigImpl(
getConfig: typeof createRequestConfig,
localeOverride?: string
) {
if (
process.env.NODE_ENV !== 'production' &&
typeof getConfig !== 'function'
) {
throw new Error(
`Invalid i18n request configuration detected.
Please verify that:
1. In case you've specified a custom location in your Next.js config, make sure that the path is correct.
2. You have a default export in your i18n request configuration file.
See also: https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request
`
);
}

let hasReadLocale = false;

// In case the consumer doesn't read `params.locale` and instead provides the
Expand Down

0 comments on commit 18b9fd6

Please sign in to comment.