Skip to content

fix(web): use base URL for synthetic page assets#811

Open
Herrtian wants to merge 2 commits into
nodejs:mainfrom
Herrtian:fix-synthetic-page-root-809
Open

fix(web): use base URL for synthetic page assets#811
Herrtian wants to merge 2 commits into
nodejs:mainfrom
Herrtian:fix-synthetic-page-root-809

Conversation

@Herrtian
Copy link
Copy Markdown

Fixes #809

Uses the configured base URL for synthetic page asset roots, so the 404 page can be served from deep links without resolving CSS and JS relative to the missing path.

Checks:

  • node --test --experimental-test-module-mocks src\generators\web\utils_tests_\processing.test.mjs
  • npx.cmd eslint src\generators\web\utils\processing.mjs src\generators\web\utils_tests_\processing.test.mjs
  • npx.cmd prettier --check src\generators\web\utils\processing.mjs src\generators\web\utils_tests_\processing.test.mjs
  • git diff --check

@Herrtian Herrtian requested a review from a team as a code owner May 27, 2026 11:55
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

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

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview May 27, 2026 12:59pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 27, 2026

PR Summary

Low Risk
Small, scoped change to template root for synthetic pages only; regular pages unchanged and behavior is covered by new unit tests.

Overview
Fixes broken CSS/JS on synthetic pages (e.g. 404) when the site is opened from a deep or missing URL path.

Page HTML rendering now uses a new resolvePageRoot helper instead of always deriving root from each page’s path. Regular pages still get the same path-relative prefix (e.g. ../ for /api/fs). Synthetic pages use / by default, or the configured baseURL (with trailing slash) when useAbsoluteURLs is enabled—so import maps and other ${root}-based asset URLs no longer point under the bogus request path.

Tests in processing.test.mjs set web generator config and cover normal pages, synthetic pages, and the absolute-URL case.

Reviewed by Cursor Bugbot for commit ba42722. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

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

look at preview root link it's just broke

@Herrtian
Copy link
Copy Markdown
Author

Herrtian commented May 27, 2026

Updated this so synthetic pages use / in relative URL mode and only use baseURL when absolute URLs are enabled. That should keep the preview assets on the preview origin.

@AugustinMauroy
Copy link
Copy Markdown
Member

just open https://api-docs-tooling-git-fork-herrtian-fix-synthetic-f9f8be-openjs.vercel.app/ on your browser and see oh broken css url

@Herrtian
Copy link
Copy Markdown
Author

The branch synced now and the latest preview points the root page stylesheet at /styles.css.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ba42722. Configure here.

Comment thread src/generators/web/utils/__tests__/processing.test.mjs
Copy link
Copy Markdown
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

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

LGTM !

Comment thread src/generators/web/utils/processing.mjs
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.

404 on deep link don't have correct css url

3 participants