Skip to content

base href value is not respected when building in version 14.0.4 #23475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 15 tasks
jlquijada opened this issue Jun 30, 2022 · 3 comments · Fixed by #23477
Closed
1 of 15 tasks

base href value is not respected when building in version 14.0.4 #23475

jlquijada opened this issue Jun 30, 2022 · 3 comments · Fixed by #23477
Assignees
Labels
2022Q3 Fixit Candidates for the Q3 2022 fix-it area: @angular-devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix workaround1: obvious

Comments

@jlquijada
Copy link

jlquijada commented Jun 30, 2022

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 14.0.3

Description

Writing the tag <base href="." /> in the <head> section of the file index.html was respected when issuing the command ng build.

Now it is replaced with <base href="/" /> which makes it impossible to load the .js and .css files needed to run the app, because they are not found if the app is not deployed on the root directory of the server.

🔬 Minimal Reproduction

Just create a new project with version 14.0.4, then modify the index.html file, <base href="." /> or <base href="./" />, and after building the resulting (dist directory) index.html should have <base href="/" /> instead of the correct configured value for the tag.

🔥 Exception or Error





🌍 Your Environment




Angular CLI: 14.0.4
Node: 16.13.2
Package Manager: npm 8.13.2
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1400.4 (cli-only)
@angular-devkit/core         14.0.4 (cli-only)
@angular-devkit/schematics   14.0.4 (cli-only)
@schematics/angular          14.0.4 (cli-only)

Anything else relevant?

@alan-agius4
Copy link
Collaborator

The base href can be set through the in the browser builder.

"build": {
  "builder": "@angular-devkit/build-angular:browser",
    "options": {
      "baseHref": ".",

See: https://angular.io/cli/build

@alan-agius4 alan-agius4 added severity5: regression workaround1: obvious area: @angular-devkit/build-angular type: bug/fix freq1: low Only reported by a handful of users who observe it rarely 2022Q3 Fixit Candidates for the Q3 2022 fix-it labels Jun 30, 2022
@alan-agius4 alan-agius4 self-assigned this Jun 30, 2022
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jun 30, 2022
…when it's not set in builder

With this change we fix a regression were we  set the base-href to `/` when the browser builder `baseHref` option is not set.

Closes angular#23475
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jun 30, 2022
…when it's not set in builder

With this change we fix a regression were we  set the base-href to `/` when the browser builder `baseHref` option is not set.

Closes angular#23475
@jlquijada
Copy link
Author

Thanks! :) This workaround fixed the problem for me.

clydin pushed a commit that referenced this issue Jun 30, 2022
…when it's not set in builder

With this change we fix a regression were we  set the base-href to `/` when the browser builder `baseHref` option is not set.

Closes #23475
clydin pushed a commit that referenced this issue Jun 30, 2022
…when it's not set in builder

With this change we fix a regression were we  set the base-href to `/` when the browser builder `baseHref` option is not set.

Closes #23475

(cherry picked from commit 8870111)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2022Q3 Fixit Candidates for the Q3 2022 fix-it area: @angular-devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix workaround1: obvious
Projects
None yet
2 participants