fix(approuter): /search 301 via middleware — unblock DEV approuter boot - #2100
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tutorials-dev-approuteris down (0/1) on DEV. PR #2099 (tag-tree-topics) added a"status": 301property to the/searchroute inapprouter/xs-app.json.@sap/approuterv16 has no route-level redirect verb and rejects the unknown property at boot: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.jsmiddleware pattern (redirects can't live in xs-app.json):xs-app.json. The deeper^/search/(.*)$→srv-apiproxy route is untouched.approuter/lib/search-redirect.js: a 301 middleware registered ininsertMiddleware.first(aftersitemapIndexRedirectHandler, before the static/proxy handlers) that redirects the exact/searchentry point to/tutorial-navigator/, preserving the query string (/search?q=cap→/tutorial-navigator/?q=cap).Verification
@sap/approuter's ownvalidators.validateXsAppA/B: origin/DEV FAILS atroutes/52/status; this branch PASSES (boot-safe).test/unit/search-redirect.test.jsgreen (matcher + handler, incl. query preservation, HEAD,/search/<path>pass-through).test/e2e/topics.spec.ts'/search/?q=redirects to the navigator' e2e assertion.Unblocks the DEV deploy.