WuYongJie ba98bf22cc feat: 添加许可证系统、Agent部署模块和Harbor镜像管理
- 新增许可证服务器 (license-server/)
- 新增 Agent 部署模块 (flnxi-agent/)
- 添加许可证验证和激活页面
- 添加 Harbor 镜像同步脚本
- 更新素材系统支持许可证验证
2025-12-15 21:19:46 +08:00

44 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { NextRequest, NextResponse } from 'next/server';
import { activate } from '@/lib/license';
export async function POST(request: NextRequest) {
try {
const { licenseKey } = await request.json();
if (!licenseKey) {
return NextResponse.json(
{ success: false, error: '请输入许可证密钥' },
{ status: 400 }
);
}
const result = await activate(licenseKey);
if (result.success) {
const response = NextResponse.json({ success: true });
// 设置许可证激活 cookie(用于 middleware 快速检查)
response.cookies.set('license_activated', 'true', {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
maxAge: 365 * 24 * 60 * 60, // 1年
path: '/',
});
return response;
} else {
return NextResponse.json(
{ success: false, error: result.error },
{ status: 400 }
);
}
} catch (error) {
console.error('激活失败:', error);
return NextResponse.json(
{ success: false, error: '服务器错误' },
{ status: 500 }
);
}
}