Skip to content

Commit

Permalink
fix: #3275 refuse on server side if hide user api key
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa committed Nov 15, 2023
1 parent d898ffc commit 9876a1a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ export function auth(req: NextRequest) {
};
}

if (serverConfig.hideUserApiKey && !!apiKey) {
return {
error: true,
msg: "you are not allowed to access openai with your own api key",
};
}

// if user does not provide an api key, inject system api key
if (!apiKey) {
const serverApiKey = serverConfig.isAzure
Expand Down

1 comment on commit 9876a1a

@czgaotian
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这么改的话,如果同时设置了私有化的第三方OPENAI_API_KEY和HIDE_USER_API_KEY=1,不能正常的请求gpt的服务了

Please sign in to comment.