Title: Leading slash added to baseHref · Issue #32030 · angular/angular-cli · GitHub
Open Graph Title: Leading slash added to baseHref · Issue #32030 · angular/angular-cli
X Title: Leading slash added to baseHref · Issue #32030 · angular/angular-cli
Description: Command build 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 20.3.11 Description Expected behavior The value of the href attribute of the
Open Graph Description: Command build 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 20.3.11 Description Expected behavior The valu...
X Description: Command build 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 20.3.11 Description Expected behavior The valu...
Opengraph URL: https://github.com/angular/angular-cli/issues/32030
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Leading slash added to baseHref","articleBody":"### Command\n\nbuild\n\n### Is this a regression?\n\n- [x] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n20.3.11\n\n### Description\n\n**Expected behavior**\n\nThe value of the `href` attribute of the `\u003cbase\u003e` tag in the built `index.html` file should start with what's defined in the `baseHref` property of the builder.\n\n**Actual behavior**\n\nA leading `/` is added when the `baseHref` value does not start with one.\n\n**Impact**\n\nWe package our built apps inside docker images that process the `index.html` file on startup to replace certain strings matching `${...}` with values from environment variables. This allows us to deliver portable docker images that can be deployed under different paths in different environments by simply setting the `BASE_HREF` environment variable.\n\nSo when building our app, we set `baseHref` in the build config to a string like `${BASE_HREF}`.\n\nWith Angular 20.3.11, this produced the following tag in `index.html` (with a localized build):\n\n```html\n\u003cbase href=\"${BASE_HREF}/en/\"/\u003e\n```\n\nSince Angular 20.3.13, we now get a leading slash added:\n\n```html\n\u003cbase href=\"/${BASE_HREF}/en/\"/\u003e\n```\n\nFor deployments where our `BASE_HREF` value is an empty string, this results in the base href value of `//en/` which is a protocol-relative URL and so all of our resources fail to load.\n\n### Minimal Reproduction\n\nCreate an Angular app with 20.3.13, set baseHref to a value that does not start with `/`, enable localization, build.\n\n### Exception or Error\n\n```text\n\n```\n\n### Your Environment\n\n```text\nAngular CLI: 20.3.13\nNode: 22.14.0\nPackage Manager: npm 10.9.2\nOS: darwin arm64\n \n\nAngular: 20.3.15\n... animations, common, compiler, compiler-cli, core, forms\n... language-service, localize, platform-browser\n... platform-browser-dynamic, router\n\nPackage Version\n------------------------------------\n@angular-devkit/architect 0.2003.13\n@angular-devkit/core 20.3.13\n@angular-devkit/schematics 20.3.13\n@angular/build 20.3.13\n@angular/cdk 20.2.14\n@angular/cli 20.3.13\n@schematics/angular 20.3.13\nrxjs 7.8.1\ntypescript 5.9.3\nzone.js 0.15.1\n```\n\n### Anything else relevant?\n\n_No response_","author":{"url":"https://github.com/daiscog","@type":"Person","name":"daiscog"},"datePublished":"2025-12-04T18:54:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/32030/angular-cli/issues/32030"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a92d0fbf-6c54-b222-102a-321f5b4263bf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 829C:363F36:3A7DA99:4D9EFC3:6964BAEC |
| html-safe-nonce | a818dacfdb16225afdf8cb11120ffcdec3e2bdbe6936a6bf61ba02cb0108635d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjlDOjM2M0YzNjozQTdEQTk5OjREOUVGQzM6Njk2NEJBRUMiLCJ2aXNpdG9yX2lkIjoiMjY1MTU1NzM4NDA0MjEwMTQ4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fd89de78852c7233f5b9156b90e790fde7573f7e0d7f15a0e00388f505caf821 |
| hovercard-subject-tag | issue:3696042910 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/32030/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eae0f5c2a6eefd0ba81197a47ef7e205400810b7d3aae7434134352c7c53dfea/angular/angular-cli/issues/32030 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eae0f5c2a6eefd0ba81197a47ef7e205400810b7d3aae7434134352c7c53dfea/angular/angular-cli/issues/32030 |
| og:image:alt | Command build 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 20.3.11 Description Expected behavior The valu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | daiscog |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9917306ebdf5f9f30d13ede7b74f08a45b5f12b401ce3e4bfabd895ea0ca0ada |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 020ceddb26807bba62dcfb410905847d63243ff5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width