A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix route redirecting on 500, login and logout
aminnausin10786c69f7ef
diff --git a/resources/js/router/index.js b/resources/js/router/index.jsindex 62f06a64..c0da0f7a 100644--- a/resources/js/router/index.js+++ b/resources/js/router/index.js@@ -32,23 +32,33 @@ const router = createRouter({path:'/logout',name:'logout',component: {- async beforeRouteEnter(from) {+ async beforeRouteEnter(to, from, next) {try {- const destination = from.fullPath === '/logout' ? '/' : (from?.meta.protected ? '/' : from.fullPath);const authStore = useAuthStore();const { clearAuthState } = authStore;-+ let nextPath = from.fullPath;+ let nextTitle = from.meta?.title ?? toTitleCase(from.name);await logout();clearAuthState();- router.push(destination);++ if(from.meta?.protected || from.name === 'logout'){+ nextPath = '/';+ nextTitle = 'Home'+ }++ document.title = nextTitle;+ next(nextPath)} catch (error) {// eslint-disable-next-line no-undeftoastr['error']('Unable to logout');console.log(error);- router.push('/');++ next('/');++ document.title = 'Home'; // Update Page Title}}- }+ }},{path:'/history',@@ -88,7 +98,16 @@ const router = createRouter({})router.beforeEach(async (to, from, next) => {- document.title = to.meta?.title ?? toTitleCase(to.name); // Update Page Title+ if(to.name !== 'logout') document.title = to.meta?.title ?? toTitleCase(to.name); // Update Page Title++ if(to.name === 'login' && !to.query.redirect && from.fullPath !== '/'){+ to.query = {+ redirect: from.name !== 'login' ? from.fullPath : null,+ }++ next();+ return;+ }if(!to.meta?.protected){ // Not protected routenext();@@ -104,11 +123,10 @@ router.beforeEach(async (to, from, next) => {}// Not logged in -> no user and page is protected-- next({+ next({name: 'login',query: {- redirect: to.fullPath,+ redirect: to.fullPath}});})diff --git a/resources/js/service/api.js b/resources/js/service/api.jsindex cdf9ec48..ab11d9e6 100644--- a/resources/js/service/api.js+++ b/resources/js/service/api.js@@ -7,7 +7,7 @@ const handleResponse = (response) => {const handleError = (error) => {// if the server throws an error (404, 500 etc.)console.log(error);- if(error.response.status === 403 || error.response.status === 500){+ if(error.response.status === 403){ //|| error.response.status === 500window.location = `/${error.response.status}?message=${error?.response?.data?.message ?? error?.message}`return;}