Search code examples
angularangular-routingangular-router

Named/Child router outlets throwing 404 if navigate to by typing in url or refreshing


I'm using named/child router-outlet to reload dynamically load data into form. The problem that I am getting is that it only works if I navigate to the route programmatically so:

this.router.navigate([
      '/printers',
      { outlets: { 'form-outlet': [selectedPrinter.id] } },
    ]);

...and this works fine but the if I try to copy and paste the URL (e.g. "http://localhost:4200/printers/(form-outlet:119)") or refresh the page while at that URL I get 404 error in the console:

Failed to load resource: the server responded with a status of 404 (Not Found)

Does anyone know why this happens and how to fix it?


Solution

  • Fixed it by changing index.html <base href="./"> to <base href="/"> without the ..