Skip to content

fix(approuter): /search 301 via middleware — unblock DEV approuter boot - #2100

Merged
jung-thomas merged 1 commit into
DEVfrom
fix/approuter-search-redirect-middleware
Sep 2, 2026
Merged

fix(approuter): /search 301 via middleware — unblock DEV approuter boot#2100
jung-thomas merged 1 commit into
DEVfrom
fix/approuter-search-redirect-middleware

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Problem

tutorials-dev-approuter is down (0/1) on DEV. PR #2099 (tag-tree-topics) added a "status": 301 property to the /search route in approuter/xs-app.json. @sap/approuter v16 has no route-level redirect verb and rejects the unknown property at boot:

VError: xs-app.json/routes/52/status: Additional properties not allowed

This crash-loops the approuter (srv/srv-qa/db all deploy fine — only the frontend is down).

Fix

Mirrors the established approuter/lib/sitemap-index-redirect.js middleware pattern (redirects can't live in xs-app.json):

  • Remove the invalid route from xs-app.json. The deeper ^/search/(.*)$srv-api proxy route is untouched.
  • Add approuter/lib/search-redirect.js: a 301 middleware registered in insertMiddleware.first (after sitemapIndexRedirectHandler, before the static/proxy handlers) that redirects the exact /search entry point to /tutorial-navigator/, preserving the query string (/search?q=cap/tutorial-navigator/?q=cap).

Verification

  • Ran @sap/approuter's own validators.validateXsApp A/B: origin/DEV FAILS at routes/52/status; this branch PASSES (boot-safe).
  • 10 new unit tests in test/unit/search-redirect.test.js green (matcher + handler, incl. query preservation, HEAD, /search/<path> pass-through).
  • Satisfies the existing test/e2e/topics.spec.ts '/search/?q= redirects to the navigator' e2e assertion.

Unblocks the DEV deploy.

…son status prop

PR #2099 added a `"status": 301` property to the /search route in
xs-app.json. @sap/approuter v16 has no route-level redirect verb and rejects
the unknown property at boot (xs-app.json/routes/52/status: Additional
properties not allowed), crash-looping tutorials-dev-approuter (0/1).

Fix mirrors the established sitemap-index-redirect.js pattern:
- remove the invalid route from xs-app.json (the deeper /search/<path>
  srv-api proxy route is untouched)
- add approuter/lib/search-redirect.js: a 301 middleware in
  insertMiddleware.first, before the static/proxy handlers, that redirects
  the exact /search entry point to /tutorial-navigator/ preserving the query
- register it in server.js after sitemapIndexRedirectHandler

Verified against @sap/approuter's own validators.validateXsApp: origin/DEV
fails at routes/52/status; this commit PASSES. 10 new unit tests green.
@jung-thomas
jung-thomas merged commit 10167af into DEV Sep 2, 2026
2 of 3 checks passed
@jung-thomas
jung-thomas deleted the fix/approuter-search-redirect-middleware branch September 2, 2026 00:43
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.

1 participant