Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add error handling in case an invalid i18n request config file has been specified #1327

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading