0.4.0 convex及界面修改
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { convexAuthNextjsMiddleware, createRouteMatcher, nextjsMiddlewareRedirect } from "@convex-dev/auth/nextjs/server";
|
||||
import { isDevAuthEnabled } from "@/lib/auth/devUser";
|
||||
|
||||
// 说明:
|
||||
// - 这里启用 Convex Auth 的 Next.js 中间件,负责:
|
||||
@@ -10,6 +11,9 @@ import { convexAuthNextjsMiddleware, createRouteMatcher, nextjsMiddlewareRedirec
|
||||
const isPublicRoute = createRouteMatcher([
|
||||
"/auth",
|
||||
"/login",
|
||||
// 说明:仅用于本地/联调的页面选项回归入口(Playwright 会用它验证页面选项是否真正生效)。
|
||||
// 该路由不写入后端数据,放行可避免 E2E 因鉴权/数据初始化问题被阻塞。
|
||||
"/dev/page-options-playground",
|
||||
"/api/auth(.*)",
|
||||
// 说明:ONLYOFFICE 文档服务器(容器/远端)拉取文件与回调保存不携带用户态,必须放行。
|
||||
"/api/onlyoffice/proxy(.*)",
|
||||
@@ -31,6 +35,10 @@ export default convexAuthNextjsMiddleware(async (request, ctx) => {
|
||||
// 注意:middleware 运行在 Edge/Node 环境中,读取到的是运行期环境变量。
|
||||
if (process.env.NEXT_PUBLIC_USE_CONVEX !== "1") return;
|
||||
|
||||
// 开发用户模式下允许“免登录”访问(主要用于迁移/联调与 E2E 回归)。
|
||||
// 注意:生产环境请勿开启 MNOTE_DEV_AUTH。
|
||||
if (isDevAuthEnabled()) return;
|
||||
|
||||
const authed = await ctx.convexAuth.isAuthenticated();
|
||||
if (!authed) {
|
||||
return nextjsMiddlewareRedirect(request, "/auth");
|
||||
|
||||
Reference in New Issue
Block a user