0

I have a web app and when I go on :

    http://localhost:8080/Test/home
http://localhost:8080/Test/login

It gives me 404, and it doesn't me the home

My app-routing.ts is:

const routes: Routes = [
  {
    path: environment.URL_LOGIN_ROUTING, loadChildren: () => import("./components/login/login.module").then(m =>
      m.LoginModule)
  },
  {
    path: environment.URL_HOME_ROUTING, component: HomeComponent, canActivate: [AuthGuard]
  },
  {path: '', redirectTo: environment.URL_LOGIN_ROUTING, pathMatch: 'full' }
  
];

in My envinroment is:

//ROUTING
const URL_LOGIN_ROUTING = "/login";
const URL_HOME_ROUTING = "/home";
export const environment = {

  //DA INSERIRE NEL ROUTING
  URL_LOGIN_ROUTING: URL_LOGIN_ROUTING,
   URL_HOME_ROUTING: URL_HOME_ROUTING,

};

I start angular with:

ng build --watch --base-href /Test/

I I go on http://localhost:8080/Test/ it work but if I go on http://localhost:8080/Test/login or

http://localhost:8080/Test/home

it gives me 404. Anyone can help me?

Picco
  • 423
  • 2
  • 6
  • 21

1 Answers1

1

Remove the preceeding / from your paths. You should never need a preceeding or a trailing / when dealing with angular Router.

const URL_LOGIN_ROUTING = "login";
const URL_HOME_ROUTING = "home";
Chris Hamilton
  • 9,252
  • 1
  • 9
  • 26