Skip to content

Ea/fix middleware issue#613

Merged
ErnestM1234 merged 8 commits intomainfrom
ea/fix-middleware-issue
Aug 29, 2025
Merged

Ea/fix middleware issue#613
ErnestM1234 merged 8 commits intomainfrom
ea/fix-middleware-issue

Conversation

@ErnestM1234
Copy link
Copy Markdown
Contributor

No description provided.

@ErnestM1234 ErnestM1234 requested a review from a team as a code owner August 29, 2025 17:22
@vercel
Copy link
Copy Markdown

vercel bot commented Aug 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
gt-docs Ready Ready Preview Comment Aug 29, 2025 5:44pm
5 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
example-ai-chatbot Ignored Ignored Aug 29, 2025 5:44pm
example-create-react-app Ignored Ignored Aug 29, 2025 5:44pm
example-gt-next-starter Ignored Ignored Aug 29, 2025 5:44pm
example-next-create-app Ignored Ignored Aug 29, 2025 5:44pm
example-vite-create-app Ignored Ignored Aug 29, 2025 5:44pm

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR addresses middleware-related issues with locale detection during Static Site Generation (SSG) in Next.js applications using General Translation. The core problem being fixed is that SSG disrupts locale resolution because Next.js request APIs (headers() and cookies()) are not available during build time.

The changes introduce several key improvements:

  1. Custom getLocale Support: Enables users to provide their own locale detection logic for SSG scenarios through a new configuration option and webpack aliasing system.

  2. Version-Aware Next.js Compatibility: Implements detection logic for different Next.js versions (15.1-15.4 uses unstable_rootParams, 15.5+ uses experimental next/root-params) to handle the evolving root parameters API.

  3. Enhanced Error Handling: Adds specific error messages that guide users to SSG documentation when locale determination fails, replacing generic errors with actionable guidance.

  4. Request Access Detection: Introduces utility functions to detect when Next.js request APIs are available before attempting to use them, preventing crashes during static generation.

  5. Documentation Updates: Adds comprehensive SSG documentation with version-specific implementation examples for custom locale resolution.

The solution maintains backward compatibility while providing a clear upgrade path for users experiencing locale detection issues in SSG environments. The changes integrate across multiple packages (next, docs) and include proper TypeScript support and webpack configuration.

Confidence score: 2/5

  • This PR addresses a legitimate issue but contains several implementation problems that could cause runtime failures
  • Score lowered due to critical logic errors in version comparison, potential silent failures in async imports, and inconsistent locale validation paths
  • Pay close attention to packages/next/src/plugin/getStableNextVersionInfo.ts and packages/next/src/next/detectRequestAccess.ts for logic errors

9 files reviewed, 8 comments

Edit Code Review Bot Settings | Greptile

Comment thread apps/docs/content/docs/en/next/guides/ssg.mdx Outdated
Comment thread apps/docs/content/docs/en/next/guides/ssg.mdx Outdated
Comment thread packages/next/src/next/detectRequestAccess.ts Outdated
Comment thread packages/next/src/request/getLocale.ts
Comment thread packages/next/src/next/getNextLocale.ts
Comment thread packages/next/package.json Outdated
Comment thread packages/next/src/plugin/getStableNextVersionInfo.ts
Comment thread packages/next/src/plugin/getStableNextVersionInfo.ts
@ErnestM1234 ErnestM1234 merged commit 48ddbd0 into main Aug 29, 2025
18 checks passed
@ErnestM1234 ErnestM1234 deleted the ea/fix-middleware-issue branch August 29, 2025 17:48
@github-actions github-actions bot mentioned this pull request Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant