I'm trying to cancel the initial path e.g.: localhost:4200/ should return an error view. Instead I want my home page to be accesible only if you navigate to something like localhost:4200/tag1/tag2.
I should be able to capture the url given and set it as home page. I have tried to do this in app-routing module but I get nothing loaded or errors saying the segments don't exist.
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {AppRoutes} from '../shared/globals/app-routes';
import {errorComponent} from '../errorComponent.ts'
export const tag1 = document.location.pathname.split('/')[1];
export const tag2 = document.location.pathname.split('/')[2];
const routes: Routes = [
{ path: 'tag1/tag2',
loadChildren: () => import('../auth/auth.module').then(m => m.AuthModule) },
{ path: '',
component: errorComponent },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }