I am attempting to change the initial path such as localhost:4200/ so that it displays an error view instead of the home page. I want the home page to only be accessible if you navigate to something like localhost:4200/tag1/tag2.
I need to be able to capture the given URL and set it as the home page. I have tried to implement this in the app-routing module, but nothing is loading or I receive errors stating that the segments do not 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 { }