mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 11:36:38 +08:00
添加middleware
This commit is contained in:
parent
8239551e8e
commit
202fddd6e8
@ -31,12 +31,7 @@ export function middleware(req: NextRequest) {
|
|||||||
const [user, pwd] = atob(authValue).split(':')
|
const [user, pwd] = atob(authValue).split(':')
|
||||||
|
|
||||||
if (user === '4dmin' && pwd === 'testpwd123') {
|
if (user === '4dmin' && pwd === 'testpwd123') {
|
||||||
return NextResponse.next()
|
// return NextResponse.next()
|
||||||
}
|
|
||||||
}else{
|
|
||||||
url.pathname = '/api/auth'
|
|
||||||
return NextResponse.rewrite(url)
|
|
||||||
}
|
|
||||||
console.log("[Auth] allowed hashed codes: ", [...serverConfig.codes]);
|
console.log("[Auth] allowed hashed codes: ", [...serverConfig.codes]);
|
||||||
console.log("[Auth] got access code:", accessCode);
|
console.log("[Auth] got access code:", accessCode);
|
||||||
console.log("[Auth] hashed access code:", hashedCode);
|
console.log("[Auth] hashed access code:", hashedCode);
|
||||||
@ -83,3 +78,8 @@ export function middleware(req: NextRequest) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
url.pathname = '/api/auth'
|
||||||
|
return NextResponse.rewrite(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user