Skip to content

URLs not prefixed with base href after update to Angular 8, breaks i18n #16179

@tuomasi

Description

@tuomasi

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • [ x] serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

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

Description

This is about an application that is German by default but also available in English, French and Italian. On Angular 7, when serving the English version with /en/ as the baseHref value provided in the angular.json configuration, it would automatically prefix every URL with /en/, so that I would redirected e.g. from localhost:8000 to localhost:8000/en. With Angular 8, opening localhost:8000 resuts in a blank page saying Cannot GET /

This bug report is a duplicate of #14925, which was prematurely closed without providing a solution on how to restore the old behaviour and doesn't allow follow-up questions...when introducing such breaking changes, I would expect a proper announcement and an explanation on how to handle the new behaviour. Nothing has been mentioned in the update guide, all related issues have been closed with the issues described being deemed "intended behaviour".

🔬 Minimal Reproduction

You can reproduce the problem by creating a minimal Angular application with the CLI.

ng new angular-i18n-basehref --interactive=false
cd angular-i18n-basehref
ng serve --baseHref=/en/

Then go to http://localhost:8000 instead of http://localhost:8000/en/

Setting "baseHref" in angular.json results in the same out come.

🌍 Your Environment


Angular CLI: 8.3.18
Node: 12.11.1
OS: darwin x64
Angular: 8.2.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.803.18
@angular-devkit/build-angular      0.803.18
@angular-devkit/build-optimizer    0.803.18
@angular-devkit/build-webpack      0.803.18
@angular-devkit/core               8.3.18
@angular-devkit/schematics         8.3.18
@angular/cdk                       8.2.3
@angular/cli                       8.3.18
@angular/http                      7.2.15
@angular/material                  8.2.3
@angular/material-moment-adapter   8.2.3
@ngtools/webpack                   8.3.18
@schematics/angular                8.3.18
@schematics/update                 0.803.18
rxjs                               6.5.3
typescript                         3.5.3
webpack                            4.39.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions