mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 03:26:38 +08:00
bug修复
This commit is contained in:
parent
d0abf899b5
commit
c617071746
@ -58,11 +58,18 @@ export async function POST(req: NextRequest) {
|
||||
const usersCollection = db.collection("users");
|
||||
// 查询用户数据
|
||||
const user = await usersCollection.findOne({ key: accessCode });
|
||||
console.log(user, accessCode);
|
||||
const tips =
|
||||
"您的链接授权已过期,为了避免恶意盗刷,\n 关注微信公众号【coder思维】\n回复关键词:`ai` 获取授权链接 \n ";
|
||||
"您的链接授权已过期,为了避免恶意盗刷,\n 请关注微信公众号【coder思维】\n回复关键词:`ai` 获取授权链接 \n ";
|
||||
if (!user) {
|
||||
return new Response(tips);
|
||||
}
|
||||
console.log("compare: ");
|
||||
console.log(
|
||||
user["expire"] < new Date().getTime(),
|
||||
user["expire"],
|
||||
new Date().getTime(),
|
||||
);
|
||||
if (user["expire"] < new Date().getTime()) {
|
||||
// 判断用户是否过期
|
||||
return new Response(tips);
|
||||
@ -95,7 +102,7 @@ export async function POST(req: NextRequest) {
|
||||
content: req.body,
|
||||
};
|
||||
collection.insertOne(chatLog).then(() => {
|
||||
client.close();
|
||||
//client.close();
|
||||
});
|
||||
|
||||
const stream = await createStream(req);
|
||||
|
@ -35,7 +35,7 @@ export const getServerSideConfig = () => {
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
code: process.env.CODE,
|
||||
codes: ACCESS_CODES,
|
||||
needCode: true,
|
||||
needCode: false,
|
||||
proxyUrl: process.env.PROXY_URL,
|
||||
isVercel: !!process.env.VERCEL,
|
||||
};
|
||||
|
@ -4,7 +4,7 @@ const cn = {
|
||||
WIP: "该功能仍在开发中……",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
"现在是未授权状态,为了避免恶意盗刷:,\n 关注微信公众号【coder思维】\n回复关键词:`ai` 获取授权链接 \n ",
|
||||
"现在是未授权状态,为了避免恶意盗刷:\n 请关注微信公众号【coder思维】\n回复关键词:`ai` 获取授权链接 \n ",
|
||||
},
|
||||
ChatItem: {
|
||||
ChatItemCount: (count: number) => `${count} 条对话`,
|
||||
@ -151,7 +151,7 @@ const cn = {
|
||||
},
|
||||
Store: {
|
||||
DefaultTopic: "新的聊天",
|
||||
BotHello: "有什么可以帮你的吗",
|
||||
BotHello: "有什么可以帮你的吗,我是智商超越人类的 AI大师",
|
||||
Error: "出错了,稍后重试吧",
|
||||
Prompt: {
|
||||
History: (content: string) =>
|
||||
|
@ -37,11 +37,9 @@ function getHeaders() {
|
||||
const accessStore = useAccessStore.getState();
|
||||
let headers: Record<string, string> = {};
|
||||
|
||||
if (accessStore.enabledAccessControl()) {
|
||||
const hash = window.location.hash.substr(1); // 获取 hash 值,去掉 #
|
||||
const params = new URLSearchParams(hash); // 创建 URLSearchParams 对象
|
||||
headers["access-code"] = params.get("key") + "";
|
||||
}
|
||||
const hash = window.location.hash.substr(1); // 获取 hash 值,去掉 #
|
||||
const params = new URLSearchParams(hash); // 创建 URLSearchParams 对象
|
||||
headers["access-code"] = params.get("key") + "";
|
||||
|
||||
if (accessStore.token && accessStore.token.length > 0) {
|
||||
headers["token"] = accessStore.token;
|
||||
|
@ -9,7 +9,7 @@ export const config = {
|
||||
const serverConfig = getServerSideConfig();
|
||||
|
||||
export function middleware(req: NextRequest) {
|
||||
console.log("req:",req)
|
||||
//console.log("req:",req)
|
||||
const accessCode = req.headers.get("access-code");
|
||||
const token = req.headers.get("token");
|
||||
const hashedCode = md5.hash(accessCode ?? "").trim();
|
||||
|
Loading…
Reference in New Issue
Block a user