Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 部署在vercel上GOOGLE_API_KEY失效的问题,希望修改获取KEY的代码部分 #3931

Closed
KevinBrk opened this issue Jan 26, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@KevinBrk
Copy link

使用中发现在vercel上设置了GOOGLE_API_KEY无效

看源代码后发现,在api/google/route.ts文件第52行直接获取头部Authorization的值,有值直接使用无值才会使用服务端配置

但是当配置访问密码CODE后,头部Authorization是一直都有nk-xxxxxxx这样格式的值导致判断错误

希望能修复这个问题,感谢!

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: [Feature] The problem of GOOGLE_API_KEY failure when deployed on vercel. I hope to modify the code part for obtaining KEY.

During use, it was found that the GOOGLE_API_KEY set on vercel was invalid.

After looking at the source code, I found that in line 52 of the [api/google/route.ts file](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/981a3629b6eeb9f41090c2a7cd4fd568f6981a55/app/api/google/%5B. ..path%5D/route.ts#L52) Directly obtain the value of the header Authorization. If there is a value, use it directly. If there is no value, the server configuration will be used.

However, after configuring the access password CODE, the Authorization header always has a value in the format of nk-xxxxxxx, which leads to incorrect judgment.

Hope this can be fixed, thanks!

@RoversX
Copy link

RoversX commented Jan 27, 2024

使用中发现在vercel上设置了GOOGLE_API_KEY无效

看源代码后发现,在api/google/route.ts文件第52行直接获取头部Authorization的值,有值直接使用无值才会使用服务端配置

但是当配置访问密码CODE后,头部Authorization是一直都有nk-xxxxxxx这样格式的值导致判断错误

希望能修复这个问题,感谢!

Same problem

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


During use, it was found that the GOOGLE_API_KEY set on vercel was invalid.

After looking at the source code, I found that in line 52 of the [api/google/route.ts file](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/981a3629b6eeb9f41090c2a7cd4fd568f6981a55/app/api/google/%5B ...path%5D/route.ts#L52) directly obtains the value of the header Authorization. If there is a value, use it directly. If there is no value, the server configuration will be used.

But when the access password CODE is configured, the Authorization header always has a value in the format of nk-xxxxxxx, which leads to an error in judgment.

Hope this can be fixed, thanks!

Same problem

@fred-bf fred-bf added the bug Something isn't working label Jan 30, 2024
@fred-bf
Copy link
Contributor

fred-bf commented Feb 4, 2024

Hi, the authorization key were injected through(a bit hacky)

req.headers.set("Authorization", `Bearer ${systemApiKey}`);

I tried to reproduce the issue, but it works fine on my end. if you still encounter please provide a reproducible environment or provide env keys you've set.

@fred-bf fred-bf closed this as completed Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants