mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-09 10:54:22 +08:00
feat: support using user api key
This commit is contained in:
@@ -8,13 +8,14 @@ export const config = {
|
||||
|
||||
export function middleware(req: NextRequest, res: NextResponse) {
|
||||
const accessCode = req.headers.get("access-code");
|
||||
const token = req.headers.get("token");
|
||||
const hashedCode = md5.hash(accessCode ?? "").trim();
|
||||
|
||||
console.log("[Auth] allowed hashed codes: ", [...ACCESS_CODES]);
|
||||
console.log("[Auth] got access code:", accessCode);
|
||||
console.log("[Auth] hashed access code:", hashedCode);
|
||||
|
||||
if (ACCESS_CODES.size > 0 && !ACCESS_CODES.has(hashedCode)) {
|
||||
if (ACCESS_CODES.size > 0 && !ACCESS_CODES.has(hashedCode) && !token) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
needAccessCode: true,
|
||||
|
Reference in New Issue
Block a user