Files
fe_supplier_frontend/src/app.ts

11 lines
295 B
TypeScript

import { history } from 'umi';
export function onRouteChange({ location }: any) {
const token = sessionStorage.getItem('token');
const whiteList = ['/login', '/user/register', '/403', '/404'];
if (!token && !whiteList.includes(location.pathname)) {
history.replace('/login');
}
}