Skip to content

Conversation

Copy link

Copilot AI commented Nov 22, 2025

Fix 404 Route Error After Permission Expiry and Re-login

Problem Analysis

After session timeout, when resetRouter() is called, it only preserves routes in the whitelist: ['Redirect', 'Login', 'NoFound', 'Home']. However, the actual home page is rendered by a child route named Index under the Home parent route. When users log back in and are redirected to /index, the Index route is missing, causing a 404 error.

Implementation Plan

  • Analyze codebase and identify the issue
  • Add Index route to the resetWhiteNameList in src/router/index.ts
  • Test the build to ensure no syntax errors
  • Verify the fix resolves the permission expiry re-login issue
  • Run code review and security checks
Original prompt

长时间没操作,权限失效后,重新登录,页面报404路由

resetRouter的时候只添加了['Redirect', 'Login', 'NoFind', 'Root'],权限失效以后重新登录后会this.addRouters丢失首页路由,麻烦修复一下

CONVERSATION SUMMARY

TITLE

Fix 404 Route Error After Permission Expiry and Re-login

USER INTENT

Fix a bug where the application shows a 404 route error after permission expires and the user logs back in, due to missing home page routes after router reset.

TASK DESCRIPTION

The user is experiencing a routing issue in their application. When a user's session expires due to inactivity and they re-login, the page shows a 404 error. The root cause is that the resetRouter function only preserves basic routes (['Redirect', 'Login', 'NoFind', 'Root']), causing the home page route to be lost when addRouters is called after re-login.

EXISTING

  • A resetRouter function exists that currently only adds basic routes: ['Redirect', 'Login', 'NoFind', 'Root']
  • An addRouters method is used to add dynamic routes
  • The application has a permission system that expires after periods of inactivity
  • After permission expiry and re-login, the home page route is missing

PENDING

  • Modify the resetRouter function to include the home page route so it's preserved during router reset
  • Ensure that after re-login, addRouters properly includes all necessary routes including the home page
  • Test the fix to verify that re-login after session expiry no longer results in 404 errors

CODE STATE

File paths mentioned (not specified in conversation):

  • Router configuration file (likely contains resetRouter function)
  • Authentication/permission handling file (likely contains login logic and addRouters call)

Current behavior:

// resetRouter only includes these routes:
['Redirect', 'Login', 'NoFind', 'Root']
// Missing home page route causes 404 after re-login

RELEVANT CODE/DOCUMENTATION SNIPPETS

None provided in the conversation, but the following would be relevant:

  • Current implementation of resetRouter function
  • Current implementation of addRouters method
  • Home page route definition
  • Login flow that calls these methods

OTHER NOTES

  • This is a session timeout/permission expiry issue
  • The bug only manifests after long periods of inactivity followed by re-login
  • The issue is specifically related to dynamic route management in the application's router system
  • This appears to be a Vue.js or similar SPA framework application based on the router terminology used

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants