Advertisement
metalni

Public Routes

Sep 6th, 2022 (edited)
1,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // src/configs/routes.ts
  2. import {IPageRoute} from "../interfaces";
  3.  
  4. export const publicRoutes: Array<IPageRoute> = [
  5.   {
  6.     path: '/forgot-password'
  7.   },
  8.   {
  9.     path: '/register'
  10.   }
  11. ]
  12.  
  13. // AuthContext.tsx
  14. if(publicRoutes.some(route => route.path.includes(router.asPath)))
  15.    router.push('/login')
  16.  
  17. // interfaces
  18.  
  19. export interface IPageRoute {
  20.   path: string
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement