Skip to content

Route Permissions


This document was generated by machine translation. If there are any errors, please inform us


Fixed Routes (Routes Accessible Without Permission)

In static route mode, route permissions are controlled by meta.constant. Routes with constant set to true can be accessed without logging in; In dynamic route mode, routes accessible without logging in need to be returned in the fetchGetConstantRoutes interface. In other words, routes with constant set to true returned in fetchGetUserRoutes will not take effect and still require login to access;

Permission Routes

In static route mode, by default, routes require login to access. To configure permissions, you can add the meta.roles field. This field's type is string[], configured in UserInfo. If a matching role is found, access is allowed, otherwise not. Matching occurs in the pre-route guard phase; In dynamic route mode, meta.roles can still be used, but it's generally preferred to let the backend control the route table return based on role permissions, excluding unauthorized routes;

Dynamic Routes

Modify the source of routes. The route table for static routes comes from ./src/router/elegant/routes.ts, while the route table for dynamic routes comes from the fetchGetConstantRoutes and fetchGetUserRoutes interfaces.


The type of the route table returned by the interface must be consistent with the frontend's static route table type. Before attempting modifications, it is advisable to familiarize yourself with the project's unique route plugin and route table structure


Enable/disable dynamic route mode by configuring the VITE_AUTH_ROUTE_MODE variable in the .env file.

Code Location


# auth route mode: static | dynamic

Publish under the MIT license