fix: 添加身份验证检查,未登录用户重定向至根目录

This commit is contained in:
2025-12-17 23:22:36 +08:00
parent 8f29ddb449
commit b9624e4f6f

View File

@@ -8,6 +8,11 @@ localProxy.initFromAssistantConfig(assistantConfig);
export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResponse) => {
const _assistantConfig = assistantConfig.getCacheAssistantConfig();
const auth = _assistantConfig?.auth;
if (!auth.username) {
res.writeHead(302, { Location: `/root/cli/setting/` });
return res.end();
}
const url = new URL(req.url, 'http://localhost');
const pathname = decodeURIComponent(url.pathname);
if (pathname === '/' && _assistantConfig?.home) {