AI 小说工坊:主编 + 作家多模型协作写作应用
- Nuxt 4 + Nuxt UI 4 + AI SDK 7 + Drizzle/SQLite - 主编规划大纲与章节简报、选派作家;作家流式写入章节文件并实时推送前端 - 逐章确认模式(默认)与自动模式;摘要与故事记忆 - 酒馆角色卡(PNG/JSON,V1-V3)与世界书导入 - 自定义最高优先级系统提示词、审稿/修改/多版本、任务日志与提示词检视 - 模拟 LLM 服务与端到端测试脚本 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { timingSafeEqual } from 'node:crypto'
|
||||
|
||||
/**
|
||||
* 可选的访问密码(HTTP Basic Auth)。
|
||||
* 设置环境变量 NOVEL_PASSWORD 后启用,用户名任意;本机使用可以不设置。
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
const password = process.env.NOVEL_PASSWORD
|
||||
if (!password) return
|
||||
const header = getHeader(event, 'authorization') || ''
|
||||
if (header.startsWith('Basic ')) {
|
||||
const decoded = Buffer.from(header.slice(6), 'base64').toString('utf8')
|
||||
const given = Buffer.from(decoded.slice(decoded.indexOf(':') + 1))
|
||||
const expected = Buffer.from(password)
|
||||
if (given.length === expected.length && timingSafeEqual(given, expected)) return
|
||||
}
|
||||
setHeader(event, 'WWW-Authenticate', 'Basic realm="AI Novel Studio", charset="UTF-8"')
|
||||
throw createError({ statusCode: 401, message: '需要访问密码' })
|
||||
})
|
||||
Reference in New Issue
Block a user