node.jsangulartypescriptangular-fullstack

show user a fake route in angular


I am working on a full stack development using Angular, Node and MySQL. I want to ask if there's a way I can add a fake route to show it to a user. Let me explain, I want to add a route of let's say:

http://localhost:4200/#/**table**

I want to show it to user as:

http://localhost:4200/#/**somefakeroute**

Behind the scenes, in my code, this path doesn't exist but, shows to user as one. Is there a way to do that in angular? To show a different route name to a user than what it really is? I want to protect my routes by doing this instead of using route guards.


Solution

  • May be you can do something better than showing fake routes.

    1. You can use encryption. Encrypting routes in angular
    2. Navigation Extras in angular, you can use this to create alias names for routes, example:
    this.router.navigate(['/view'], { skipLocationChange: true });