Skip to content

Conversation

@edmundhung
Copy link
Contributor

@edmundhung edmundhung commented Jan 5, 2026

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

  • Chores
    • Updated preview server configuration to bind to the loopback address for local development.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

A 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

Cohort / File(s) Summary
Vite Preview Server Configuration
packages/start-plugin-core/src/prerender.ts
Added explicit host: '127.0.0.1' binding to Vite preview server configuration alongside existing port and open settings

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

package: start-plugin-core

Suggested reviewers

  • birkskyum

Poem

🐰 A loopback fix for Docker's plight,
Where interfaces dance out of sight,
Now 127.0.0.1 shines clear,
Prerender jobs no longer fear,
The server listens, all is right! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly describes the main change: fixing prerendering issues when building with Docker, which matches the primary objective of binding the preview server to 127.0.0.1.
Linked Issues check ✅ Passed The code change directly addresses issue #6275 by binding the Vite preview server to 127.0.0.1, which solves the Docker build connection failures caused by network URL resolution pointing to non-listening interfaces.
Out of Scope Changes check ✅ Passed The single change to bind the preview server to 127.0.0.1 is directly scoped to fixing the Docker prerendering issue; no unrelated modifications are present.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c189259 and 0d605f6.

📒 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: Confirm resolvedUrls.local population with loopback binding.

The getResolvedUrl function depends on previewServer.resolvedUrls?.local[0] being populated. Please verify that when the preview server is bound to 127.0.0.1, the resolvedUrls.local array is correctly populated with the loopback address.

Assuming Vite correctly populates resolvedUrls.local for the loopback binding, the integration is sound and the prerendering flow should work correctly.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Jan 5, 2026

View your CI Pipeline Execution ↗ for commit 0d605f6

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 16m 47s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 20s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-05 09:53:32 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 5, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6305

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6305

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6305

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6305

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6305

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6305

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6305

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6305

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6305

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6305

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6305

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6305

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6305

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6305

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6305

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6305

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6305

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6305

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6305

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6305

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6305

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6305

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6305

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6305

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6305

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6305

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6305

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6305

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6305

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6305

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6305

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6305

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6305

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6305

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6305

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6305

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6305

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6305

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6305

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6305

commit: 0d605f6

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 for http://localhost redirects but will now receive http://127.0.0.1:PORT URLs 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

📥 Commits

Reviewing files that changed from the base of the PR and between c189259 and 0d605f6.

📒 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: Confirm resolvedUrls.local population with loopback binding.

The getResolvedUrl function depends on previewServer.resolvedUrls?.local[0] being populated. Please verify that when the preview server is bound to 127.0.0.1, the resolvedUrls.local array is correctly populated with the loopback address.

Assuming Vite correctly populates resolvedUrls.local for 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',
Copy link
Member

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prerendering does not work when building Docker container

2 participants