From d849024cb1ada9fcf891b2da00e6a5cfd088bd5a Mon Sep 17 00:00:00 2001 From: linshen <32978552+linshenkx@users.noreply.github.com> Date: Tue, 27 May 2025 23:14:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(docker):=20=E6=B7=BB=E5=8A=A0=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E8=AE=A4=E8=AF=81=E5=8A=9F=E8=83=BD=E5=92=8C=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 Dockerfile 中添加 htpasswd 工具和 dos2unix - 更新 docker-compose.yml 文件以支持 ACCESS_USERNAME 和 ACCESS_PASSWORD 环境变量 - 修改 dev.md 和 README 文件,增加访问密码配置说明 - 更新 Nginx 配置以引入基本认证 - 将版本号更新至 1.0.6 --- Dockerfile | 17 +++++++- README.md | 21 +++++++--- README_EN.md | 16 ++++++-- dev.md | 2 +- docker-compose.yml | 5 +++ docker/generate-auth.sh | 46 +++++++++++++++++++++ docker/nginx.conf | 3 ++ docs/vercel-password-protection.md | 58 --------------------------- docs/vercel-password-protection_zh.md | 58 --------------------------- docs/vercel.md | 26 ++++++++---- docs/vercel_en.md | 28 ++++++++----- package.json | 2 +- 12 files changed, 136 insertions(+), 146 deletions(-) create mode 100644 docker/generate-auth.sh delete mode 100644 docs/vercel-password-protection.md delete mode 100644 docs/vercel-password-protection_zh.md diff --git a/Dockerfile b/Dockerfile index ef47001e..5934797b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,10 +10,25 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile RUN pnpm run build FROM nginx:stable-alpine +# 安装htpasswd工具和dos2unix +RUN apk add --no-cache apache2-utils dos2unix + +# 复制Nginx配置 COPY docker/nginx.conf /etc/nginx/conf.d/default.conf + +# 复制Web应用 COPY --from=build /app/packages/web/dist /usr/share/nginx/html -# 复制启动脚本 + +# 复制并设置启动脚本 COPY docker/generate-config.sh /docker-entrypoint.d/40-generate-config.sh +COPY docker/generate-auth.sh /docker-entrypoint.d/30-generate-auth.sh + +# 确保脚本有执行权限 RUN chmod +x /docker-entrypoint.d/40-generate-config.sh +RUN chmod +x /docker-entrypoint.d/30-generate-auth.sh + +# 转换可能的Windows行尾符为Unix格式 +RUN dos2unix /docker-entrypoint.d/40-generate-config.sh +RUN dos2unix /docker-entrypoint.d/30-generate-auth.sh EXPOSE 80 \ No newline at end of file diff --git a/README.md b/README.md index 6305e43a..2c02bc74 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ![GitHub forks](https://img.shields.io/github/forks/linshenkx/prompt-optimizer?style=flat) [![Deploy with Vercel](https://img.shields.io/badge/Vercel-indigo?style=flat&logo=vercel)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flinshenkx%2Fprompt-optimizer) -[在线体验](https://prompt.always200.com) | [快速开始](#快速开始) | [常见问题](#常见问题) | [开发文档](dev.md) | [Vercel部署指南](docs/vercel.md) ([密码保护](docs/vercel-password-protection_zh.md)) | [Chrome插件](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna) +[在线体验](https://prompt.always200.com) | [快速开始](#快速开始) | [常见问题](#常见问题) | [开发文档](dev.md) | [Vercel部署指南](docs/vercel.md) | [Chrome插件](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna) @@ -53,10 +53,12 @@ Prompt Optimizer是一个强大的AI提示词优化工具,帮助你编写更 - 先Fork项目到自己的GitHub - 然后在Vercel中导入该项目 - 可跟踪源项目更新,便于同步最新功能和修复 - +- 配置环境变量: + - `ACCESS_PASSWORD`:设置访问密码,启用访问限制 + - `VITE_OPENAI_API_KEY`等:配置各AI服务商的API密钥 + 更多详细的部署步骤和注意事项,请查看: - [Vercel部署指南](docs/vercel.md) -- [Vercel密码保护指南](docs/vercel-password-protection_zh.md) ### 3. 安装Chrome插件 1. 从Chrome商店安装(由于审批较慢,可能不是最新的):[Chrome商店地址](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna) @@ -67,12 +69,15 @@ Prompt Optimizer是一个强大的AI提示词优化工具,帮助你编写更 # 运行容器(默认配置) docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer linshen/prompt-optimizer -# 运行容器(配置API密钥) +# 运行容器(配置API密钥和访问密码) docker run -d -p 80:80 \ -e VITE_OPENAI_API_KEY=your_key \ + -e ACCESS_USERNAME=your_username \ # 可选,默认为"admin" + -e ACCESS_PASSWORD=your_password \ # 设置访问密码 --restart unless-stopped \ --name prompt-optimizer \ linshen/prompt-optimizer + ``` ### 5. Docker Compose部署 @@ -81,11 +86,16 @@ docker run -d -p 80:80 \ git clone https://github.com/linshenkx/prompt-optimizer.git cd prompt-optimizer -# 2. 可选:创建.env文件配置API密钥 +# 2. 可选:创建.env文件配置API密钥和访问认证 cat > .env << EOF +# API密钥配置 VITE_OPENAI_API_KEY=your_openai_api_key VITE_GEMINI_API_KEY=your_gemini_api_key VITE_DEEPSEEK_API_KEY=your_deepseek_api_key + +# Basic认证配置(密码保护) +ACCESS_USERNAME=your_username # 可选,默认为"admin" +ACCESS_PASSWORD=your_password # 设置访问密码 EOF # 3. 启动服务 @@ -171,7 +181,6 @@ pnpm dev:fresh # 完整重置并重新启动开发环境 - [项目状态](docs/project-status.md) - 当前进度和计划 - [产品需求](docs/prd.md) - 产品需求文档 - [Vercel部署指南](docs/vercel.md) - Vercel部署详细说明 -- [Vercel密码保护指南](docs/vercel-password-protection_zh.md) - Vercel密码保护详细说明 ## Star History diff --git a/README_EN.md b/README_EN.md index 2f7a2bde..689dc8b0 100644 --- a/README_EN.md +++ b/README_EN.md @@ -53,10 +53,12 @@ Method 2: Fork the project and import to Vercel (Recommended): - First fork the project to your GitHub account - Then import the project to Vercel - This allows tracking of source project updates for easy syncing of new features and fixes +- Configure environment variables: + - `ACCESS_PASSWORD`: Set access password to enable access restriction + - `VITE_OPENAI_API_KEY` etc.: Configure API keys for various AI service providers For more detailed deployment steps and important notes, please check: - [Vercel Deployment Guide](docs/vercel_en.md) -- [Vercel Password Protection Guide](docs/vercel-password-protection.md) ### 3. Install Chrome Extension 1. Install from Chrome Web Store (may not be the latest version due to approval delays): [Chrome Web Store](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna) @@ -67,9 +69,11 @@ For more detailed deployment steps and important notes, please check: # Run container (default configuration) docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer linshen/prompt-optimizer -# Run container (with API key configuration) +# Run container (with API key configuration and password protection) docker run -d -p 80:80 \ -e VITE_OPENAI_API_KEY=your_key \ + -e ACCESS_USERNAME=your_username \ # Optional, defaults to "admin" + -e ACCESS_PASSWORD=your_password \ # Required for password protection --restart unless-stopped \ --name prompt-optimizer \ linshen/prompt-optimizer @@ -81,11 +85,16 @@ docker run -d -p 80:80 \ git clone https://github.com/linshenkx/prompt-optimizer.git cd prompt-optimizer -# 2. Optional: Create .env file for API keys +# 2. Optional: Create .env file for API keys and authentication cat > .env << EOF +# API Key Configuration VITE_OPENAI_API_KEY=your_openai_api_key VITE_GEMINI_API_KEY=your_gemini_api_key VITE_DEEPSEEK_API_KEY=your_deepseek_api_key + +# Basic Authentication +ACCESS_USERNAME=your_username # Optional, defaults to "admin" +ACCESS_PASSWORD=your_password # Required for authentication EOF # 3. Start the service @@ -171,7 +180,6 @@ For detailed project status, see [Project Status Document](docs/project-status.m - [Project Status](docs/project-status.md) - Current progress and plans - [Product Requirements](docs/prd.md) - Product requirements document - [Vercel Deployment Guide](docs/vercel_en.md) - Detailed instructions for Vercel deployment -- [Vercel Password Protection Guide](docs/vercel-password-protection.md) - Detailed instructions for Vercel password protection ## Star History diff --git a/dev.md b/dev.md index 29be8e04..6c1a57be 100644 --- a/dev.md +++ b/dev.md @@ -51,7 +51,7 @@ docker build -t linshen/prompt-optimizer:$VERSION . docker tag linshen/prompt-optimizer:$VERSION linshen/prompt-optimizer:latest # 运行容器 -docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer linshen/prompt-optimizer:$VERSION +docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer -e ACCESS_PASSWORD=1234!@#$ linshen/prompt-optimizer:$VERSION # 推送 diff --git a/docker-compose.yml b/docker-compose.yml index 80ef0316..4ede7f3d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,5 @@ +version: '3' + services: prompt-optimizer: image: linshen/prompt-optimizer:latest @@ -22,6 +24,9 @@ services: - VITE_CUSTOM_API_KEY=${VITE_CUSTOM_API_KEY:-} - VITE_CUSTOM_API_BASE_URL=${VITE_CUSTOM_API_BASE_URL:-} - VITE_CUSTOM_API_MODEL=${VITE_CUSTOM_API_MODEL:-} + # Basic认证配置(可选) + - ACCESS_USERNAME=${ACCESS_USERNAME:-admin} # 可选,默认为"admin" + - ACCESS_PASSWORD=${ACCESS_PASSWORD:-} # 设置访问密码 # 健康检查 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:80"] diff --git a/docker/generate-auth.sh b/docker/generate-auth.sh new file mode 100644 index 00000000..bfc58850 --- /dev/null +++ b/docker/generate-auth.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# 检查是否设置了ACCESS_PASSWORD环境变量 +if [ -n "$ACCESS_PASSWORD" ]; then + # 检查密码是否为空字符串 + if [ "$ACCESS_PASSWORD" = "" ]; then + echo "警告: 设置了空密码,不安全。不启用Basic认证" + # 创建空的auth配置(禁用认证) + cat > /etc/nginx/conf.d/auth.conf << EOF +# Basic认证未启用 - 密码为空 +auth_basic off; +EOF + exit 0 + fi + + echo "启用Basic认证..." + + # 创建认证文件目录 + mkdir -p /etc/nginx/auth + + # 确定用户名(如果未设置ACCESS_USERNAME则使用默认值"admin") + USERNAME=${ACCESS_USERNAME:-admin} + + # 生成htpasswd文件 - 使用printf避免特殊字符问题 + printf '%s' "$ACCESS_PASSWORD" | htpasswd -i -c /etc/nginx/auth/.htpasswd "$USERNAME" + + # 容器环境中简化权限管理 - 确保所有人都可读取认证文件 + chmod -R a+r /etc/nginx/auth + + # 创建启用认证的配置 + cat > /etc/nginx/conf.d/auth.conf << EOF +# 此文件由generate-auth.sh脚本自动生成 +auth_basic "请输入访问凭据 (Please enter your credentials)"; +auth_basic_user_file /etc/nginx/auth/.htpasswd; +EOF + + echo "Basic认证已配置,用户名: $USERNAME" +else + echo "未设置ACCESS_PASSWORD环境变量,不启用Basic认证" + + # 创建空的auth配置(禁用认证) + cat > /etc/nginx/conf.d/auth.conf << EOF +# Basic认证未启用 +auth_basic off; +EOF +fi \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf index 9d598d22..b1e7809d 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -38,6 +38,9 @@ server { # SPA应用路由支持 location / { + # 引入Basic认证配置 + include /etc/nginx/conf.d/auth.conf; + try_files $uri $uri/ /index.html; expires -1; add_header Cache-Control "no-store, no-cache, must-revalidate"; diff --git a/docs/vercel-password-protection.md b/docs/vercel-password-protection.md deleted file mode 100644 index f590d7eb..00000000 --- a/docs/vercel-password-protection.md +++ /dev/null @@ -1,58 +0,0 @@ -# Vercel Deployment Password Protection - -This document explains how to enable and use the password protection feature for your Vercel deployment. This feature uses Next.js Middleware and Vercel API Functions with an elegant authentication page to restrict access to your deployed application. - -## How it Works - -When password protection is enabled, users attempting to access your Vercel deployment will be intercepted by middleware: -- If they are not authenticated, they will see an elegant password verification page. -- If they enter the correct password, they will be granted access to the application. A cookie is set in their browser to remember their session, so they won't need to re-enter the password for a certain period (e.g., 7 days) or until they clear their cookies. -- If they enter an incorrect password, they will be shown an error message and prompted to try again. -- The verification page automatically displays in either Chinese or English based on the user's browser language settings. - -This protection works entirely through Next.js Middleware and Vercel API without modifying the main web application code. - -## Setup Instructions - -1. **Set the Access Password Environment Variable:** - * Go to your project settings in Vercel. - * Navigate to "Settings" -> "Environment Variables". - * Create a new environment variable named `ACCESS_PASSWORD`. - * Set its value to the password you want to use for accessing the site. Choose a strong, unique password. - * Ensure the variable is available to all environments you wish to protect (Production, Preview, Development). - * When you add or change environment variables, Vercel will prompt you to redeploy your project. Follow the prompts to complete the redeployment. - -2. **Accessing Your Protected Site:** - * Once the `ACCESS_PASSWORD` is set and the project has redeployed, try accessing your Vercel deployment URL. - * You should see a password verification page. - * Enter the password you configured in the `ACCESS_PASSWORD` environment variable. - * Upon successful authentication, the page will reload and show the main application. - -## Technical Details - -- **Technology Used:** - - Next.js Middleware (`middleware.js`) for intercepting all page requests and serving the verification page - - Vercel API Functions (`/api/auth.js`) for server-side password verification - - Language-adaptive verification page (automatically displays in Chinese or English based on browser language) -- **Cookie Name:** `vercel_access_token` (This cookie stores the access password. It's HttpOnly, Secure in production, and SameSite=Strict). -- **Password Storage:** The actual password is only stored as an environment variable in your Vercel project settings. It is not hardcoded in the application. -- **Bypassing Protection:** If the `ACCESS_PASSWORD` environment variable is not set or is empty, the password protection will be bypassed, and the site will be publicly accessible. This allows for easy disabling of the feature if needed. -- **Non-invasive Implementation:** This protection is completely independent of the main web application code. All logic is contained in the `middleware.js` and `api/auth.js` files. -- **Security Note:** This is a presentation-layer protection that can be bypassed by users who disable JavaScript or directly access API endpoints. For stronger security, consider using Vercel's built-in password protection feature. -- **Multi-language Support:** The verification page automatically detects the browser's `accept-language` header to display a Chinese interface for Chinese users and an English interface for users of other languages. - -## Troubleshooting - -- **Password verification page doesn't appear:** - * Ensure the `ACCESS_PASSWORD` environment variable is correctly set in Vercel and that the project has finished redeploying. - * Check the browser console for any errors related to the middleware or authentication API. - * Verify that the `/api/auth` endpoint is working by accessing it directly. -- **Incorrect password error, even with the correct password:** - * Double-check the value of the `ACCESS_PASSWORD` environment variable for typos or extra spaces. - * Try clearing your browser cookies for the site and attempting again. - * Check the browser network tab to see if the API call is successful. -- **Language display issues:** - * If the verification page language doesn't match your browser settings, confirm that your browser has the correct preferred language settings. - * You can switch the display language of the verification page by modifying your browser's language settings. - -For further assistance, please check the project's main README or open an issue in the repository. diff --git a/docs/vercel-password-protection_zh.md b/docs/vercel-password-protection_zh.md deleted file mode 100644 index 4536d2f6..00000000 --- a/docs/vercel-password-protection_zh.md +++ /dev/null @@ -1,58 +0,0 @@ -# Vercel 部署密码保护 - -本文档说明如何为您的 Vercel 部署启用和使用密码保护功能。此功能使用 Next.js Middleware 和 Vercel API 函数,通过美观的身份验证页面来限制对您已部署应用程序的访问。 - -## 工作原理 - -启用密码保护后,尝试访问您的 Vercel 部署的用户将被中间件拦截: -- 如果他们未经身份验证,将看到一个美观的密码验证页面。 -- 如果他们输入正确的密码,他们将被授予访问应用程序的权限。一个 Cookie 会被设置在他们的浏览器中以记住他们的会话,因此他们在一段时间内(例如 7 天)或直到他们清除 Cookie 之前无需重新输入密码。 -- 如果他们输入错误的密码,他们将看到错误消息并被提示重试。 -- 验证页面会根据用户浏览器语言设置自动选择显示中文或英文界面。 - -此保护完全通过 Next.js Middleware 和 Vercel API 实现,无需修改主要的 web 应用程序代码。 - -## 设置说明 - -1. **设置访问密码环境变量:** - * 进入您在 Vercel 中的项目设置。 - * 导航到"Settings"->"Environment Variables"。 - * 创建一个名为 `ACCESS_PASSWORD` 的新环境变量。 - * 将其值设置为您希望用于访问站点的密码。选择一个强壮且唯一的密码。 - * 确保该变量在您希望保护的所有环境(生产、预览、开发)中都可用。 - * 当您添加或更改环境变量时,Vercel 会提示您重新部署项目。请按照提示完成重新部署。 - -2. **访问受保护的站点:** - * 一旦设置了 `ACCESS_PASSWORD` 并且项目已重新部署,请尝试访问您的 Vercel 部署 URL。 - * 您应该会看到一个密码验证页面。 - * 输入您在 `ACCESS_PASSWORD` 环境变量中配置的密码。 - * 成功验证后,页面将重新加载并显示主应用程序。 - -## 技术细节 - -- **所用技术:** - - Next.js Middleware(`middleware.js`)用于拦截所有页面请求并提供验证页面 - - Vercel API 函数(`/api/auth.js`)用于服务端密码验证 - - 自适应语言的验证页面(根据浏览器语言自动显示中文或英文) -- **Cookie 名称:** `vercel_access_token`(此 Cookie 存储访问密码。它是 HttpOnly,在生产环境中是 Secure,并且 SameSite=Strict)。 -- **密码存储:** 实际密码仅作为环境变量存储在您的 Vercel 项目设置中。它没有硬编码在应用程序中。 -- **绕过保护:** 如果未设置 `ACCESS_PASSWORD` 环境变量或该变量为空,则密码保护将被绕过,站点将公开访问。这允许在需要时轻松禁用该功能。 -- **非侵入性实现:** 此保护完全独立于主要的 web 应用程序代码。所有逻辑都包含在 `middleware.js` 和 `api/auth.js` 文件中。 -- **安全说明:** 这是表现层保护,可以被禁用 JavaScript 或直接访问 API 端点的用户绕过。如需更强的安全性,请考虑使用 Vercel 的内置密码保护功能。 -- **多语言支持:** 验证页面会自动检测浏览器的 `accept-language` 请求头,为中文用户显示中文界面,为其他语言用户显示英文界面。 - -## 故障排除 - -- **密码验证页面未出现:** - * 确保在 Vercel 中正确设置了 `ACCESS_PASSWORD` 环境变量,并且项目已完成重新部署。 - * 检查浏览器控制台中是否有与中间件或身份验证 API 相关的任何错误。 - * 通过直接访问 `/api/auth` 端点来验证它是否正常工作。 -- **即使使用正确的密码也提示密码错误:** - * 仔细检查 `ACCESS_PASSWORD` 环境变量的值是否有拼写错误或多余的空格。 - * 尝试清除站点的浏览器 Cookie,然后重试。 - * 检查浏览器网络选项卡以查看 API 调用是否成功。 -- **语言显示问题:** - * 如果验证页面语言与您的浏览器设置不符,请确认您的浏览器已正确设置首选语言。 - * 您可以通过修改浏览器的语言设置来切换验证页面的显示语言。 - -如需进一步帮助,请查看项目的主 README 文件或在存储库中提交问题。 diff --git a/docs/vercel.md b/docs/vercel.md index 069da502..2fd2cfc6 100644 --- a/docs/vercel.md +++ b/docs/vercel.md @@ -39,20 +39,23 @@ ![清空根目录设置](../images/vercel/setting.png) -4. **重新部署项目** - - 设置保存后,需要手动触发重新部署以使修复生效 +4. **配置环境变量(可选)** + - 部署完成后,进入项目设置 + - 点击"Environment Variables" + - 添加需要的API密钥(例如`VITE_OPENAI_API_KEY`) + - 如需添加访问限制功能: + - 添加名为`ACCESS_PASSWORD`的环境变量 + - 设置一个安全的密码作为其值 + - 保存环境变量设置 + +5. **重新部署项目** + - 设置保存后,需要手动触发重新部署以使修复和环境变量生效 - 点击顶部导航栏中的"Deployments" - 在最新的部署记录右侧,点击"..."按钮 - 选择"Redeploy"选项触发重新部署 ![重新部署项目](../images/vercel/redeploy.png) -5. **配置环境变量(可选)** - - 部署完成后,进入项目设置 - - 点击"Environment Variables" - - 添加需要的API密钥(例如`VITE_OPENAI_API_KEY`) - - 重新部署项目使环境变量生效 - 6. **同步上游更新** - 在GitHub上打开你fork的项目 - 如果有更新,会显示"This branch is X commits behind linshenkx:main" @@ -94,6 +97,13 @@ Prompt Optimizer在Vercel部署时支持使用Edge Runtime代理解决跨域问 - 部分模型服务提供商可能会限制来自Vercel的请求 - 如遇限制,建议使用自部署的API中转服务 +### 密码保护访问 + +当配置了`ACCESS_PASSWORD`环境变量后,您的站点将启用密码保护功能: +- 访问站点时会显示密码验证页面 +- 输入正确密码后可访问应用 +- 系统会设置Cookie记住用户,一段时间内无需重复输入密码 + ### 常见问题 1. **部署后页面空白或报错** diff --git a/docs/vercel_en.md b/docs/vercel_en.md index 32c897e1..3fd68efc 100644 --- a/docs/vercel_en.md +++ b/docs/vercel_en.md @@ -39,20 +39,23 @@ This method allows you to track project updates, making it easier to sync the la ![Clear root directory setting](../images/vercel/setting.png) -4. **Redeploy the project** - - After saving the settings, you need to manually trigger a redeployment to make the fix effective +4. **Configure environment variables (Optional)** + - After deployment is complete, go to project settings + - Click "Environment Variables" + - Add the required API keys (e.g., `VITE_OPENAI_API_KEY`) + - To add access restriction functionality: + - Add an environment variable named `ACCESS_PASSWORD` + - Set a secure password as its value + - Save the environment variable settings + +5. **Redeploy the project** + - After saving the settings, you need to manually trigger a redeployment to make the fixes and environment variables effective - Click "Deployments" in the top navigation bar - On the right side of the latest deployment record, click the "..." button - Select the "Redeploy" option to trigger redeployment ![Redeploy the project](../images/vercel/redeploy.png) -5. **Configure environment variables (Optional)** - - After deployment is complete, go to project settings - - Click "Environment Variables" - - Add the required API keys (e.g., `VITE_OPENAI_API_KEY`) - - Redeploy the project to make the environment variables effective - 6. **Sync upstream updates** - Open your forked project on GitHub - If there are updates, it will show "This branch is X commits behind linshenkx:main" @@ -70,6 +73,13 @@ If you only need quick deployment and don't care about subsequent updates, you c **Advantage:** With one-click deployment, Vercel can automatically correctly identify the root directory, no manual fixing required, and all features (including Vercel proxy) can work normally. +### Password Protected Access + +When the `ACCESS_PASSWORD` environment variable is configured, your site will enable password protection: +- A password verification page will be displayed when accessing the site +- Access to the application is granted after entering the correct password +- The system will set a cookie to remember the user, eliminating the need to re-enter the password for a period of time + ### About Vercel Proxy Functionality Prompt Optimizer supports using Edge Runtime proxy to solve cross-origin issues when deployed on Vercel. @@ -117,4 +127,4 @@ Prompt Optimizer supports using Edge Runtime proxy to solve cross-origin issues 5. **How to add a custom domain** - Select "Domains" in the Vercel project settings - Add and verify your domain - - Follow the guidance to configure DNS records + - Follow the guidance to configure DNS records \ No newline at end of file diff --git a/package.json b/package.json index 2615a425..028dceb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prompt-optimizer", - "version": "1.0.5", + "version": "1.0.6", "private": true, "packageManager": "pnpm@10.6.1", "engines": {