Skip to content

Commit e0f6c80

Browse files
authored
Merge pull request #812 from Yidadaa/bugfix-0415
refactor: remove protocol env vars
2 parents f5a05da + ad274b7 commit e0f6c80

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ We recommend that you follow the steps below to re-deploy:
9797
- Choose and deploy in Vercel again, [please see the detailed tutorial](./docs/vercel-cn.md).
9898

9999
### Enable Automatic Updates
100+
100101
After forking the project, due to the limitations imposed by Github, you need to manually enable Workflows and Upstream Sync Action on the Actions page of the forked project. Once enabled, automatic updates will be scheduled every hour:
101102

102103
![Automatic Updates](./docs/images/enable-actions.jpg)
103104

104105
![Enable Automatic Updates](./docs/images/enable-actions-sync.jpg)
105106

106107
### Manually Updating Code
108+
107109
If you want to update instantly, you can check out the [Github documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) to learn how to synchronize a forked project with upstream code.
108110

109111
You can star or watch this project or follow author to get release notifictions in time.
@@ -134,17 +136,11 @@ Access passsword, separated by comma.
134136

135137
### `BASE_URL` (optional)
136138

137-
> Default: `api.openai.com`
138-
139-
Override openai api request base url.
139+
> Default: `https://api.openai.com`
140140
141-
### `PROTOCOL` (optional)
141+
> Examples: `http://your-openai-proxy.com`
142142
143-
> Default: `https`
144-
145-
> Values: `http` | `https`
146-
147-
Override openai api request protocol.
143+
Override openai api request base url.
148144

149145
## Development
150146

README_CN.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- 在 Vercel 重新选择并部署,[请查看详细教程](./docs/vercel-cn.md#如何新建项目)
4444

4545
### 打开自动更新
46+
4647
当你 fork 项目之后,由于 Github 的限制,需要手动去你 fork 后的项目的 Actions 页面启用 Workflows,并启用 Upstream Sync Action,启用之后即可开启每小时定时自动更新:
4748

4849
![自动更新](./docs/images/enable-actions.jpg)
@@ -85,17 +86,13 @@ OpanAI 密钥,你在 openai 账户页面申请的 api key。
8586

8687
### `BASE_URL` (可选)
8788

88-
> Default: `api.openai.com`
89-
90-
OpenAI 接口代理 URL,如果你手动配置了 openai 接口代理,请填写此选项。
89+
> Default: `https://api.openai.com`
9190
92-
### `PROTOCOL` (可选)
91+
> Examples: `http://your-openai-proxy.com`
9392
94-
> Default: `https`
95-
96-
> Values: `http` | `https`
93+
OpenAI 接口代理 URL,如果你手动配置了 openai 接口代理,请填写此选项。
9794

98-
OpenAI 代理接口协议,如果遇到 ssl 证书问题,请尝试通过此选项设置为 http。
95+
> 如果遇到 ssl 证书问题,请将 `BASE_URL` 的协议设置为 http。
9996
10097
## 开发
10198

app/api/common.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ export async function requestOpenai(req: NextRequest) {
99
const apiKey = req.headers.get("token");
1010
const openaiPath = req.headers.get("path");
1111

12+
let baseUrl = BASE_URL;
13+
14+
if (!baseUrl.startsWith("http")) {
15+
baseUrl = `${PROTOCOL}://${baseUrl}`;
16+
}
17+
1218
console.log("[Proxy] ", openaiPath);
19+
console.log("[Base Url]", baseUrl);
1320

14-
return fetch(`${PROTOCOL}://${BASE_URL}/${openaiPath}`, {
21+
return fetch(`${baseUrl}/${openaiPath}`, {
1522
headers: {
1623
"Content-Type": "application/json",
1724
Authorization: `Bearer ${apiKey}`,

0 commit comments

Comments
 (0)