-
Notifications
You must be signed in to change notification settings - Fork 127
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 prerendered dynamic ISR functions for nested routes #900
base: main
Are you sure you want to change the base?
Fix prerendered dynamic ISR functions for nested routes #900
Conversation
🦋 Changeset detectedLatest commit: 337a40a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I have used your npm package to replace cf/next-on-pages, but the error appear again
⚡️ ERROR: Failed to produce a Cloudflare Pages build from the project. |
The issue with /[locale] should have already been fixed in cloudflare’s package. Also make sure you have replaced everything with the package. Including the dependencies. |
Thank you, i have remove node_modules, but the error appear again.
here is my package.json
|
Mind sharing your page.tsx of the /[locale] route? |
Of course, I have been troubled by this question for many days. src/app/[locale]/layout.js
src/app/[locale]/page.js
|
I use the same library in my project, it has to do with some static rendering. For every page you need to set the request locale using https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering.
On top of that I would suggest you to use in the layout this instead: export default async function RootLayout({ children, params: { locale } }) {
if (!locale || !routing.locales.includes(locale as any)) {
notFound();
}
setRequestLocale(locale);
const messages = await getMessages();
return (
<html lang={locale}>
<head>
<link rel="alternate" href="/en" hrefLang="en" />
<link rel="alternate" href="/zh" hrefLang="zh" />
<link rel="alternate" href="/en" hrefLang="x-default" />
</head>
<body className={inter.className}>
<NextIntlClientProvider locale={locale} messages={messages}>
{children}
</NextIntlClientProvider>
</body>
</html>
);
} |
Thank you for pointing out the issue with setRequestLocale, which can lead to incorrect locale during SSR, but the Edge Runtime issue still persists.
|
The
|
This expands on the change in #834 and #864 to fix prerendered routes with nested routes (e.g.
[locale]/test/page.tsx
->nl/test
anden/test
).I ran into an issue when adding localization with pre-rendered pages to my project on Cloudflare Pages. Everything generally worked, but dynamic routes with nested structures failed to build without
export const runtime = 'edge';
, which shouldn’t be required. This fix applies similar logic to handle nested dynamic ISR routes as with simple dynamic routes.This PR fixes #899, if you would like to use the changes immediately the package is released on @rickmartensnl/next-on-pages.