From ec46a06b1386bd091e67a2d49ff399d5a19448f9 Mon Sep 17 00:00:00 2001 From: CNSeniorious000 Date: Wed, 19 Apr 2023 13:16:09 +0800 Subject: [PATCH] fix: sign mechanism failure #376 Fixed Naming inconsistency causing sign mechanism failure, modified files include: - .env.example - docker-compose.yml - README.md - README.zh-CN.md - docker-env-replace.sh - env.d.ts --- .env.example | 2 +- README.md | 6 +++--- README.zh-CN.md | 6 +++--- docker-compose.yml | 2 +- hack/docker-env-replace.sh | 4 ++-- src/env.d.ts | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.env.example b/.env.example index 56b28dfc4..a69ae47f0 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,7 @@ OPENAI_API_BASE_URL= # Inject analytics or other scripts before of the page HEAD_SCRIPTS= # Secret string for the project. Use for generating signatures for API calls -SECRET_KEY= +PUBLIC_SECRET_KEY= # Set password for site, support multiple password separated by comma. If not set, site will be public SITE_PASSWORD= # ID of the model to use. https://platform.openai.com/docs/api-reference/models/list diff --git a/README.md b/README.md index a6431e93a..2cb7207ac 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ A demo repo based on [OpenAI GPT-3.5 Turbo API.](https://platform.openai.com/doc ### Deploy With Netlify -[![Deploy with Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ddiu8081/chatgpt-demo#OPENAI_API_KEY=&HTTPS_PROXY=&OPENAI_API_BASE_URL=&HEAD_SCRIPTS=&SECRET_KEY=&OPENAI_API_MODEL=&SITE_PASSWORD=) +[![Deploy with Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ddiu8081/chatgpt-demo#OPENAI_API_KEY=&HTTPS_PROXY=&OPENAI_API_BASE_URL=&HEAD_SCRIPTS=&PUBLIC_SECRET_KEY=&OPENAI_API_MODEL=&SITE_PASSWORD=) **Step-by-step deployment tutorial:** @@ -111,7 +111,7 @@ services: # - HTTPS_PROXY=YOUR_HTTPS_PROXY # - OPENAI_API_BASE_URL=YOUR_OPENAI_API_BASE_URL # - HEAD_SCRIPTS=YOUR_HEAD_SCRIPTS - # - SECRET_KEY=YOUR_SECRET_KEY + # - PUBLIC_SECRET_KEY=YOUR_SECRET_KEY # - SITE_PASSWORD=YOUR_SITE_PASSWORD # - OPENAI_API_MODEL=YOUR_OPENAI_API_MODEL ``` @@ -137,7 +137,7 @@ You can control the website through environment variables. | `HTTPS_PROXY` | Provide proxy for OpenAI API. e.g. `http://127.0.0.1:7890` | `null` | | `OPENAI_API_BASE_URL` | Custom base url for OpenAI API. | `https://api.openai.com` | | `HEAD_SCRIPTS` | Inject analytics or other scripts before `` of the page | `null` | -| `SECRET_KEY` | Secret string for the project. Use for generating signatures for API calls | `null` | +| `PUBLIC_SECRET_KEY` | Secret string for the project. Use for generating signatures for API calls | `null` | | `SITE_PASSWORD` | Set password for site, support multiple password separated by comma. If not set, site will be public | `null` | | `OPENAI_API_MODEL` | ID of the model to use. [List models](https://platform.openai.com/docs/api-reference/models/list) | `gpt-3.5-turbo` | diff --git a/README.zh-CN.md b/README.zh-CN.md index d9cc197b3..9b99e414c 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -59,7 +59,7 @@ ### 部署在 Netlify -[![Deploy with Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ddiu8081/chatgpt-demo#OPENAI_API_KEY=&HTTPS_PROXY=&OPENAI_API_BASE_URL=&HEAD_SCRIPTS=&SECRET_KEY=&OPENAI_API_MODEL=&SITE_PASSWORD=) +[![Deploy with Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ddiu8081/chatgpt-demo#OPENAI_API_KEY=&HTTPS_PROXY=&OPENAI_API_BASE_URL=&HEAD_SCRIPTS=&PUBLIC_SECRET_KEY=&OPENAI_API_MODEL=&SITE_PASSWORD=) **分步部署教程:** @@ -103,7 +103,7 @@ services: # - HTTPS_PROXY=YOUR_HTTPS_PROXY # - OPENAI_API_BASE_URL=YOUR_OPENAI_API_BASE_URL # - HEAD_SCRIPTS=YOUR_HEAD_SCRIPTS - # - SECRET_KEY=YOUR_SECRET_KEY + # - PUBLIC_SECRET_KEY=YOUR_SECRET_KEY # - SITE_PASSWORD=YOUR_SITE_PASSWORD # - OPENAI_API_MODEL=YOUR_OPENAI_API_MODEL ``` @@ -129,7 +129,7 @@ docker-compose down | `HTTPS_PROXY` | 为 OpenAI API 提供代理. e.g. `http://127.0.0.1:7890` | `null` | | `OPENAI_API_BASE_URL` | 请求 OpenAI API 的自定义 Base URL. | `https://api.openai.com` | | `HEAD_SCRIPTS` | 在页面的 `` 之前注入分析或其他脚本 | `null` | -| `SECRET_KEY` | 项目的秘密字符串。用于生成 API 调用的签名 | `null` | +| `PUBLIC_SECRET_KEY` | 项目的秘密字符串。用于生成 API 调用的签名 | `null` | | `SITE_PASSWORD` | 为网站设置密码,支持使用英文逗号创建多个密码。如果未设置,则该网站将是公开的 | `null` | | `OPENAI_API_MODEL` | 使用的 OpenAI 模型. [模型列表](https://platform.openai.com/docs/api-reference/models/list) | `gpt-3.5-turbo` | diff --git a/docker-compose.yml b/docker-compose.yml index 4871435be..1063b99ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: # - HTTPS_PROXY=YOUR_HTTPS_PROXY # - OPENAI_API_BASE_URL=YOUR_OPENAI_API_BASE_URL # - HEAD_SCRIPTS=YOUR_HEAD_SCRIPTS - # - SECRET_KEY=YOUR_SECRET_KEY + # - PUBLIC_SECRET_KEY=YOUR_SECRET_KEY # - SITE_PASSWORD=YOUR_SITE_PASSWORD # - OPENAI_API_MODEL=YOUR_OPENAI_API_MODEL diff --git a/hack/docker-env-replace.sh b/hack/docker-env-replace.sh index 199cb3ff4..48c40eadd 100644 --- a/hack/docker-env-replace.sh +++ b/hack/docker-env-replace.sh @@ -9,7 +9,7 @@ openai_api_base_url=$OPENAI_API_BASE_URL # Inject analytics or other scripts before of the page head_scripts=$HEAD_SCRIPTS # Secret string for the project. Use for generating signatures for API calls -secret_key=$SECRET_KEY +public_secret_key=$PUBLIC_SECRET_KEY # Set password for site, support multiple password separated by comma. If not set, site will be public site_password=$SITE_PASSWORD # ID of the model to use. https://platform.openai.com/docs/api-reference/models/list @@ -20,7 +20,7 @@ for file in $(find ./dist -type f -name "*.mjs"); do s/({}).HTTPS_PROXY/\"$https_proxy\"/g; s/({}).OPENAI_API_BASE_URL/\"$openai_api_base_url\"/g; s/({}).HEAD_SCRIPTS/\"$head_scripts\"/g; - s/({}).SECRET_KEY/\"$secret_key\"/g; + s/({}).PUBLIC_SECRET_KEY/\"$public_secret_key\"/g; s/({}).OPENAI_API_MODEL/\"$openai_api_model\"/g; s/process.env.SITE_PASSWORD/\"$site_password\"/g" $file > tmp mv tmp $file diff --git a/src/env.d.ts b/src/env.d.ts index e02209e85..4d60ac788 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -5,7 +5,7 @@ interface ImportMetaEnv { readonly HTTPS_PROXY: string readonly OPENAI_API_BASE_URL: string readonly HEAD_SCRIPTS: string - readonly SECRET_KEY: string + readonly PUBLIC_SECRET_KEY: string readonly SITE_PASSWORD: string readonly OPENAI_API_MODEL: string }