René's URL Explorer Experiment


Title: ssr: string redirectTo drops trailing slash in query and fragment · Issue #34511 · angular/angular-cli · GitHub

Open Graph Title: ssr: string redirectTo drops trailing slash in query and fragment · Issue #34511 · angular/angular-cli

X Title: ssr: string redirectTo drops trailing slash in query and fragment · Issue #34511 · angular/angular-cli

Description: Command build, serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was none, same baseHref join is there since 19.0.0 Description String redirectTo lo...

Open Graph Description: Command build, serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was none, same baseHref join is there since...

X Description: Command build, serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was none, same baseHref join is there since...

Opengraph URL: https://github.com/angular/angular-cli/issues/34511

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ssr: string redirectTo drops trailing slash in query and fragment","articleBody":"### Command\n\nbuild, serve\n\n### Is this a regression?\n\n- [ ] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\nnone, same baseHref join is there since 19.0.0\n\n### Description\n\nString `redirectTo` loses trailing `/` of query or fragment in `Location`: `'/login?next=/a/'` gives `/login?next=/a` and `'/login#section/'` gives `/login#section`. Same with `X-Forwarded-Prefix` and with base href `/base/`, on 22.2.4 and on main snapshot `22.3.0-next.3+sha-928169a`\n\nFunction redirect with same target keeps it (`/login?next=%2Fa%2F` and `/login#section/`) since router serializes it, so same target gives diffrent `Location` depending only on how redirect is written\n\n### Minimal Reproduction\n\n1. `npx -p @angular/cli@latest ng new repro --ssr --defaults --skip-git`\n2. `src/app/app.routes.ts`:\n\n```ts\nimport { Component } from '@angular/core';\nimport { Routes } from '@angular/router';\n\n@Component({ template: 'login' })\nclass Login {}\n\nexport const routes: Routes = [\n  { path: 'login', component: Login },\n  { path: 'old', redirectTo: '/login?next=/a/' },\n  { path: 'old-hash', redirectTo: '/login#section/' },\n  { path: 'old-fn', redirectTo: () => '/login?next=/a/' },\n  { path: 'old-fn-hash', redirectTo: () => '/login#section/' },\n];\n```\n\n3. `src/app/app.routes.server.ts`: `[{ path: '**', renderMode: RenderMode.Server }]` so function redirects go through render\n4. `ng build` then `NG_ALLOWED_HOSTS=localhost NG_TRUST_PROXY_HEADERS=x-forwarded-prefix node dist/repro/server/server.mjs`\n5. curl:\n\n```text\n$ curl -si localhost:4000/old | grep -i '^location'\nlocation: /login?next=/a\n$ curl -si localhost:4000/old-hash | grep -i '^location'\nlocation: /login#section\n$ curl -si localhost:4000/old-fn | grep -i '^location'\nlocation: /login?next=%2Fa%2F\n$ curl -si localhost:4000/old-fn-hash | grep -i '^location'\nlocation: /login#section/\n$ curl -si -H 'X-Forwarded-Prefix: /app' localhost:4000/old | grep -i '^location'\nlocation: /app/login?next=/a\n$ curl -si -H 'X-Forwarded-Prefix: /app' localhost:4000/old-hash | grep -i '^location'\nlocation: /app/login#section\n```\n\nWith `ng build --base-href /base/` it's `/base/login?next=/a` and `/base/login#section`. Slash is gone already at build time, `dist/repro/server/angular-app-manifest.mjs` has `\"redirectTo\": \"/login?next=/a\"`\n\nExpected: `/login?next=/a/` and `/login#section/`, with `/app` or `/base` in front when set\n\nActual: trailing slash of query and fragment is gone\n\n### Exception or Error\n\n```text\nnone, only Location header is wrong\n```\n\n### Your Environment\n\n```text\nAngular CLI       : 22.2.4\nAngular           : 22.2.3\nNode.js           : 24.16.0\nPackage Manager   : npm 11.13.0\nOperating System  : darwin arm64\n\n┌───────────────────────────┬───────────────────┬───────────────────┐\n│ Package                   │ Installed Version │ Requested Version │\n├───────────────────────────┼───────────────────┼───────────────────┤\n│ @angular/build            │ 22.2.4            │ ^22.2.4           │\n│ @angular/cli              │ 22.2.4            │ ^22.2.4           │\n│ @angular/common           │ 22.2.3            │ ^22.2.0           │\n│ @angular/compiler         │ 22.2.3            │ ^22.2.0           │\n│ @angular/compiler-cli     │ 22.2.3            │ ^22.2.0           │\n│ @angular/core             │ 22.2.3            │ ^22.2.0           │\n│ @angular/forms            │ 22.2.3            │ ^22.2.0           │\n│ @angular/platform-browser │ 22.2.3            │ ^22.2.0           │\n│ @angular/platform-server  │ 22.2.3            │ ^22.2.0           │\n│ @angular/router           │ 22.2.3            │ ^22.2.0           │\n│ @angular/ssr              │ 22.2.4            │ ^22.2.4           │\n│ rxjs                      │ 7.8.2             │ ~7.8.0            │\n│ typescript                │ 6.0.3             │ ~6.0.2            │\n│ vitest                    │ 5.0.5             │ ^5.0.0            │\n└───────────────────────────┴───────────────────┴───────────────────┘\n\nsame output with @angular/ssr 22.3.0-next.3+sha-928169a from angular-ssr-builds\n```\n\n### Anything else relevant?\n\n`joinUrlParts` trims trailing `/` of every part, and two places still pass it whole target with query and fragment: [`joinUrlParts(baseHref, metadata.redirectTo)`](https://github.com/angular/angular-cli/blob/928169a68b522b8f38334ee2626687704495e5ec/packages/angular/ssr/src/routes/ng-routes.ts#L900) in `extractRoutesAndCreateRouteTree` and [prefix join](https://github.com/angular/angular-cli/blob/928169a68b522b8f38334ee2626687704495e5ec/packages/angular/ssr/src/app.ts#L170-L173) in `AngularServerApp.handle`\n\n[#34467](https://github.com/angular/angular-cli/pull/34467) description says `joinUrlParts` is applied only to path portion when prepending `baseHref` or `X-Forwarded-Prefix` so trailing slashes in query or fragment are preserved, but both joins above still take whole target. If that's not intended I can send PR that splits off query and fragment first, like `resolveRedirectTo` does\n","author":{"url":"https://github.com/thekhegay","@type":"Person","name":"thekhegay"},"datePublished":"2026-10-23T16:19:26Z","url":"https://github.com/angular/angular-cli/issues/34511"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:27d03aa8-a7b0-766a-2fa0-114791e65137
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8220:236B3F:A9C3DA:EE9094:6AFDCEE7
html-safe-nonce034321f47430c65b1d7246c131eff240ddf0b5f6c56f554f18d69ccea2f4f48a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjIwOjIzNkIzRjpBOUMzREE6RUU5MDk0OjZBRkRDRUU3IiwidmlzaXRvcl9pZCI6Ijg4NzY0NDk3NjYxNjcxMzgwMjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacafe356a6ec10c2f6b4586d2293f7d88203ac1ca61a3bcba06b524ddba733bac1
hovercard-subject-tagissue:6001436534
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/34511/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4e8172cb90799c8c5818cbf7818ac37a536a0fbb57b66fbe5f065aa167b11556/angular/angular-cli/issues/34511
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4e8172cb90799c8c5818cbf7818ac37a536a0fbb57b66fbe5f065aa167b11556/angular/angular-cli/issues/34511
og:image:altCommand build, serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was none, same baseHref join is there since...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamethekhegay
hostnamegithub.com
expected-hostnamegithub.com
None26886a40b582b821a7a76351e0a2f42b6d6160854b6e2520db24f31fd7be5da7
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release68ebaa631a1d248d69ebde4b9c5defd3a19aeb2f
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/34511#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F34511
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F34511
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/34511
Reloadhttps://github.com/angular/angular-cli/issues/34511
Reloadhttps://github.com/angular/angular-cli/issues/34511
angularhttps://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Codehttps://github.com/angular/angular-cli
Issues196 (196)https://github.com/angular/angular-cli/issues
Pull requests20 (20)https://github.com/angular/angular-cli/pulls
Actionshttps://github.com/angular/angular-cli/actions
Security and quality8 (8)https://github.com/angular/angular-cli/security
Insightshttps://github.com/angular/angular-cli/insights
https://github.com/angular/angular-cli
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/34511
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/34511
#34512https://github.com/angular/angular-cli/pull/34512
ssr: string redirectTo drops trailing slash in query and fragmenthttps://github.com/angular/angular-cli/issues/34511#top
#34512https://github.com/angular/angular-cli/pull/34512
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
needsTriagehttps://github.com/angular/angular-cli/milestone/11
https://github.com/thekhegay
thekhegayhttps://github.com/thekhegay
on Oct 23, 2026https://github.com/angular/angular-cli/issues/34511#issue-6001436534
joinUrlParts(baseHref, metadata.redirectTo)https://github.com/angular/angular-cli/blob/928169a68b522b8f38334ee2626687704495e5ec/packages/angular/ssr/src/routes/ng-routes.ts#L900
prefix joinhttps://github.com/angular/angular-cli/blob/928169a68b522b8f38334ee2626687704495e5ec/packages/angular/ssr/src/app.ts#L170-L173
#34467https://github.com/angular/angular-cli/pull/34467
angular-robothttps://github.com/apps/angular-robot
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
on Oct 23, 2026https://github.com/angular/angular-cli/issues/34511#event-34070240692
angular-robothttps://github.com/apps/angular-robot
needsTriagehttps://github.com/angular/angular-cli/milestone/11
on Oct 23, 2026https://github.com/angular/angular-cli/issues/34511#event-34070243828
alan-agius4https://github.com/alan-agius4
on Oct 23, 2026https://github.com/angular/angular-cli/issues/34511#event-34080535523
fix(@angular/ssr): preserve trailing slashes in query and fragment of…https://github.com/alan-agius4/angular-cli/commit/a77eaddbdeb1c2fc21f2bb97b22c0b76d0561c48
https://docs.github.com/articles/closing-issues-via-commit-messages
a77eaddhttps://github.com/alan-agius4/angular-cli/commit/a77eaddbdeb1c2fc21f2bb97b22c0b76d0561c48
alan-agius4https://github.com/alan-agius4
completedhttps://github.com/angular/angular-cli/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#34512https://github.com/angular/angular-cli/pull/34512
on Oct 26, 2026https://github.com/angular/angular-cli/issues/34511#event-34240432989
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular-cli/issues/34511
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/34511
area: @angular/ssrhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fssr%22
needsTriageNo due datehttps://github.com/angular/angular-cli/milestone/11
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.