Skip to content

Angular 8 routing with serve-path and deploy-url is broken on refresh #15295

@eplatzek

Description

@eplatzek

🐞 bug report

Affected Package

angular/*@8.0.6

Is this a regression?

This used to work in:
angular/*@7.2.4

Description

When using the "serve-path" and "deploy-url" with ng serve, the live reload is broken for routing upon a reload.

🔬 Minimal Reproduction

Repository here:
https://github.com/eplatzek/ng8reloadbug/

Steps to reproduce (using new projects):
Using angular/cli @ 8.0.6
ng new ng8
ng g c my-component



update app.component.ts to:

constructor(private router: Router) {
  this.router.navigate(['my-route']);
}



update app-routing.module.ts to:



const routes: Routes = [
  {
    path: 'my-route',
    component: MyComponentComponent
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: true })],
  exports: [RouterModule]
})

update package.json:

”start": "ng serve --aot --serve-path /my-app/ --deploy-url /my-app/“,

Run Yarn start.
Navigate to:
 http://localhost:4200/my-app. The user is redirected to:
http://localhost:4200/#/my-route by the app component.


On page reload at http://localhost:4200/#/my-route, the page displays “Cannot GET /“.

The network tab of the dev tools shows a 404 for http://localhost:4200/.

Doing the same exact steps for angular/cli @ 7.2.4 will produce a working page refresh.

🔥 Exception or Error


“Cannot GET /“

🌍 Your Environment

Angular Version:


Angular CLI: 8.0.6
Node: 10.12.0
OS: darwin x64
Angular: 8.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.6
@angular-devkit/build-angular     0.800.6
@angular-devkit/build-optimizer   0.800.6
@angular-devkit/build-webpack     0.800.6
@angular-devkit/core              8.0.6
@angular-devkit/schematics        8.0.6
@angular/cli                      8.0.6
@ngtools/webpack                  8.0.6
@schematics/angular               8.0.6
@schematics/update                0.800.6
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

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