进一步优化认证流程

This commit is contained in:
sijinhui
2024-03-31 01:18:47 +08:00
parent cea656ec9a
commit 013bb7ca01
4 changed files with 33 additions and 27 deletions

View File

@@ -159,21 +159,22 @@ export async function requestLog(
}
const baseUrl = "http://localhost:3000";
const ip = getIP(req);
let h_userName = await getSessionName();
console.log("[中文]", h_userName, baseUrl);
let { session, name } = await getSessionName();
console.log("[中文]", name, session, baseUrl);
const logData = {
ip: ip,
path: url_path,
logEntry: JSON.stringify(jsonBody),
model: url_path.startsWith("mj/") ? "midjourney" : jsonBody?.model, // 后面尝试请求是添加到参数
userName: h_userName,
userName: name,
userID: session?.user?.id,
};
await fetch(`${baseUrl}/api/logs/openai`, {
method: "POST",
headers: {
"Content-Type": "application/json",
// ...req.headers,
},
body: JSON.stringify(logData),
});

View File

@@ -9,12 +9,13 @@ async function handle(
) {
try {
const request_data = await req.json();
if (request_data?.userName) {
await insertUser({
name: request_data?.userName,
email: request_data?.userName,
});
}
console.log("log", request_data);
// if (request_data?.userName) {
// await insertUser({
// name: request_data?.userName,
// email: request_data?.userName,
// });
// }
// console.log("===========4", request_data);
try {
if (request_data?.logEntry) {