0

I'm trying to generate a custom access denied page by redirecting to a new component. But it still goes to access denied path and says page not found 404. Any suggestions?

I tried to redirect to a new component when an unknown path is found assuming it as access denied path.

{ path: 'accessDenied', component: AccessDeniedComponent },
{ path: '**', redirectTo: '/accessDenied' }

I expect to load AccessDeniedComponent, but it shows page not found recognizing as the path doesn't exist.

Zhubei Federer
  • 1,274
  • 2
  • 10
  • 27

2 Answers2

0

You have to redirect all 404 of your webserver to the index.html so that angular can control it.

You can do it as fallow:

JohnnyDevNull
  • 951
  • 1
  • 8
  • 20
0

If you are only checking for unauthorised request then you should catch error in interceptor and check error code.

If error code is 401 (http code for unauthorised) then navigate to the UnAuthorised URL.

It should work. As I am using this process.

vikas
  • 16
  • 1