-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: prerendering with docker build #6305
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
📝 WalkthroughWalkthroughA single configuration change binds the Vite preview server to the loopback address (127.0.0.1) in the prerender process, addressing connectivity issues that occur in Docker environments where the server must be explicitly accessible at a specific interface. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{js,ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
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 |
|
View your CI Pipeline Execution ↗ for commit 0d605f6
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/start-plugin-core/src/prerender.ts (1)
265-287: Update redirect handling to account for the 127.0.0.1 host binding.The
host: '127.0.0.1'configuration is valid for Vite 7.1.7 and correctly binds the preview server to the loopback interface. However, the redirect detection logic (line 81) only checks forhttp://localhostredirects but will now receivehttp://127.0.0.1:PORTURLs when the server is bound to 127.0.0.1. This causes absolute redirects to the preview server to be incorrectly flagged as external redirects.Update the condition to also handle the baseUrl origin:
const baseUrlOrigin = baseUrl.origin if (location.startsWith(baseUrlOrigin) || location.startsWith('http://localhost') || location.startsWith('/')) { const newUrl = location.replace(baseUrlOrigin, '').replace('http://localhost', '') return localFetch(newUrl, options, maxRedirects - 1) }This ensures internal redirects are followed regardless of whether the server is accessed via localhost or 127.0.0.1.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/start-plugin-core/src/prerender.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript strict mode with extensive type safety for all code
Files:
packages/start-plugin-core/src/prerender.ts
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Implement ESLint rules for router best practices using the ESLint plugin router
Files:
packages/start-plugin-core/src/prerender.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (1)
packages/start-plugin-core/src/prerender.ts (1)
289-297: ConfirmresolvedUrls.localpopulation with loopback binding.The
getResolvedUrlfunction depends onpreviewServer.resolvedUrls?.local[0]being populated. Please verify that when the preview server is bound to127.0.0.1, theresolvedUrls.localarray is correctly populated with the loopback address.Assuming Vite correctly populates
resolvedUrls.localfor the loopback binding, the integration is sound and the prerendering flow should work correctly.
| return await vite.preview({ | ||
| configFile: viteConfig.configFile, | ||
| preview: { | ||
| host: '127.0.0.1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably make the host configurable for the prerenderer, since there are instances where people might want to set it to 0.0.0.0 as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users can already control the host via the preview server config as I mentioned in the original issue. I wonder if it would be simpler to rely on the existing setting and document how it affects prerendering, instead of introducing a prerender-specific option here.
Fix #6275
This binds the vite preview server to 127.0.0.1 to avoid Docker build failure caused by resolved network URLs pointing to non-listening interfaces.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.