-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(examples): fix paraglide middleware usage in start-i18n-paraglide example #6172
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughUpdates to the React/TanStack Start Paraglide i18n example, including simplified server middleware invocation, enhanced Vite plugin configuration, and URL rewriting examples. Documentation adjustments accompany code pattern refinements. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{js,ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
i need to look closer into that, this might just be a bug in router instead the example being incorrect |
|
@schiller-manuel I thought about that too, but wasn't sure. |
This PR fixes an issue where the
start-i18n-paraglideexample causes infinite 307 redirect loops in production environments (e.g., Netlify) or when cookie strategies are involved.The Issue:
The
paraglideMiddlewareautomatically de-localizes the URL (e.g.,/en/about->/about) in therequestobject passed to its callback.However, the example also configures a
rewritein the TanStack Router:By passing the already de-localized request from the middleware to
handler.fetch(request), TanStack Start receives a URL that conflicts with its internal routing/rewrite logic during SSR. This leads to mismatching states where the middleware tries to enforce cookies/redirects while the router tries to handle the URL, resulting in a redirect loop.The Fix:
We strictly use
paraglideMiddlewareto set theAsyncLocalStoragecontext (for translations), but we pass the originalreqtohandler.fetch. This allows TanStack Router to handle the URL rewriting via its configuredrewriteproperty as intended.Note:
.../paraglide-js/examples/tanstack-start) also seems to be broken/404, but fixing this inline code snippet is the most important part for users getting started.Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.