Pablo C. García
Pablo C. García

Reputation: 22394

Routing default 404 not working

When I go to www.myweb.com/something the web will display the message:

{
  "status": 404,
  "message": "No Content"
}

Here is my app.routes:

export const routes: RouterConfig = [
  { path: '', redirectTo: 'account', pathMatch: 'full' },
  { path: 'account', component: Account },
  { path: 'followers', component: Followers },
  { path: 'explore/:id', component: Explore },
  { path: '**', redirectTo: 'account' },
  ];

Im using angular universal, so I have another file called server.ts whit this code:

// Routes with html5pushstate
// ensure routes match client-side-app
app.get('/', ngApp);
app.get('/followers', ngApp);
app.get('/followers/*', ngApp);
app.get('/account', ngApp);
app.get('/account/*', ngApp);
app.get('/explore', ngApp);
app.get('/explore/*', ngApp);

Where is the problem? Thanks!

Upvotes: 0

Views: 186

Answers (1)

Madhu Ranjan
Madhu Ranjan

Reputation: 17894

You can try below,

 // notice the slash in front of account navigation
 { path: '**', redirectTo: '/account' } 

It makes navigation absolute if the path does not match.

Upvotes: 1

Related Questions