[RFC] 116 - 保护路由模式 #8032
arvinxx
started this conversation in
RFC | 特性开发
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
背景
目前,LobeChat 的大部分路由均可匿名访问。很多 issue 提到了希望在公开场景下先完成登录,再进入具体内部页面 的需求。
之前不太清楚怎么做,今年在做过 #5461 后对于 middleware 有了更加深入的了解,因此应该可以做了。
本 RFC 旨在为 LobeChat 添加受保护路由 (Protected Routes) 功能。该功能将限制对应用程序中特定页面的访问,要求用户必须先完成身份验证才能进入这些页面,未通过身份验证的用户将被重定向到登录页面。
设计思路
核心实现将依赖 Next.js 的中间件 (Middleware) 功能,在请求到达页面组件之前进行统一的身份验证检查和路由控制。
通过环境变量:
ENABLE_AUTH_PROTECTION
开启。进展
Beta Was this translation helpful? Give feedback.
All reactions