Skip to content

fix(core): print fallback URL when HTML is disabled#7534

Merged
chenjiahan merged 2 commits into
mainfrom
chenjiahan/fix-print-urls-fallback
Apr 24, 2026
Merged

fix(core): print fallback URL when HTML is disabled#7534
chenjiahan merged 2 commits into
mainfrom
chenjiahan/fix-print-urls-fallback

Conversation

@chenjiahan

@chenjiahan chenjiahan commented Apr 24, 2026

Copy link
Copy Markdown
Member

Summary

  • print the server.base URL when HTML generation is disabled and at least one environment targets the web
  • keep non-web apps silent when there is no fallback route to print

Copilot AI review requested due to automatic review settings April 24, 2026 03:07
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rsbuild with  Cloudflare Pages  Cloudflare Pages

Latest commit: 49ba24d
Status: ✅  Deploy successful!
Preview URL: https://8f66af97.rsbuild-v2.pages.dev
Branch Preview URL: https://chenjiahan-fix-print-urls-fa.rsbuild-v2.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures the dev server still prints a useful URL when HTML generation is disabled (resulting in no HTML routes), by falling back to printing the server.base URL when at least one environment targets web. It also adds a regression test and updates the English/Chinese docs accordingly.

Changes:

  • Add a fallbackPathname mechanism so printServerURLs can print a default route even when routes is empty.
  • In dev server startup, compute fallbackPathname from server.base when there are no HTML routes but at least one web target exists.
  • Add a regression test and update docs (EN/ZH) describing the new behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/docs/zh/config/server/print-urls.mdx Documents the new fallback printing behavior when HTML is disabled.
website/docs/en/config/server/print-urls.mdx Documents the new fallback printing behavior when HTML is disabled.
packages/core/tests/server.test.ts Adds a regression test covering the fallback pathname printing.
packages/core/src/server/helper.ts Extends printServerURLs to optionally synthesize a printable route from fallbackPathname.
packages/core/src/server/devServer.ts Computes and passes fallbackPathname for web-targeted environments with no HTML routes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/server/helper.ts Outdated
Comment thread packages/core/src/server/devServer.ts Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request ensures that the dev server prints a base URL even when no HTML routes are generated, such as in SSR or backend-integrated applications, provided a 'web' target is present. It introduces fallbackPathname logic in the dev server and helper functions, accompanied by unit tests and documentation updates. Feedback was provided to explicitly check for undefined when evaluating the fallback pathname to correctly handle cases where the server base might be an empty string.

Comment thread packages/core/src/server/helper.ts Outdated
@chenjiahan chenjiahan merged commit de8a224 into main Apr 24, 2026
5 checks passed
@chenjiahan chenjiahan deleted the chenjiahan/fix-print-urls-fallback branch April 24, 2026 03:21
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.

2 participants