Skip to content

Commit 1587554

Browse files
author
linzehao
committed
docs(vercel): 添加 Vercel 部署指南
1 parent 5d4244c commit 1587554

File tree

7 files changed

+278
-12
lines changed

7 files changed

+278
-12
lines changed

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
![GitHub forks](https://img.shields.io/github/forks/linshenkx/prompt-optimizer?style=flat)
1313
[![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)
1414

15-
[在线体验](https://prompt.always200.com) | [快速开始](#快速开始) | [常见问题](#常见问题) | [开发文档](dev.md) | [Chrome插件](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna)
15+
[在线体验](https://prompt.always200.com) | [快速开始](#快速开始) | [常见问题](#常见问题) | [开发文档](dev.md) | [Vercel部署指南](docs/vercel.md) | [Chrome插件](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna)
1616

1717
</div>
1818

@@ -41,15 +41,26 @@ Prompt Optimizer是一个强大的AI提示词优化工具,帮助你编写更
4141

4242
### 1. 使用在线版本(推荐)
4343

44-
1. 直接访问:[https://prompt.always200.com](https://prompt.always200.com)
45-
2. 或者一键部署到自己的Vercel:
44+
直接访问:[https://prompt.always200.com](https://prompt.always200.com)
45+
46+
项目是纯前端项目,所有数据只存储在浏览器本地,不会上传至任何服务器,因此直接使用在线版本也是安全可靠的
47+
48+
### 2. Vercel部署
49+
1. 一键部署到自己的Vercel:
4650
[![部署到 Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flinshenkx%2Fprompt-optimizer)
4751

48-
### 2. 安装Chrome插件
52+
2. Fork项目后在Vercel中导入(推荐):
53+
- 先Fork项目到自己的GitHub
54+
- 然后在Vercel中导入该项目
55+
- 可跟踪源项目更新,便于同步最新功能和修复
56+
57+
更多详细的部署步骤和注意事项,请查看 [Vercel部署指南](docs/vercel.md)
58+
59+
### 3. 安装Chrome插件
4960
1. 从Chrome商店安装(由于审批较慢,可能不是最新的):[Chrome商店地址](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna)
5061
2. 点击图标即可打开提示词优化器
5162

52-
### 3. Docker部署
63+
### 4. Docker部署
5364
```bash
5465
# 运行容器(默认配置)
5566
docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer linshen/prompt-optimizer
@@ -62,7 +73,7 @@ docker run -d -p 80:80 \
6273
linshen/prompt-optimizer
6374
```
6475

65-
### 4. Docker Compose部署
76+
### 5. Docker Compose部署
6677
```bash
6778
# 1. 克隆仓库
6879
git clone https://github.com/linshenkx/prompt-optimizer.git
@@ -157,6 +168,7 @@ pnpm dev:fresh # 完整重置并重新启动开发环境
157168
- [项目结构](docs/project-structure.md) - 详细的项目结构说明
158169
- [项目状态](docs/project-status.md) - 当前进度和计划
159170
- [产品需求](docs/prd.md) - 产品需求文档
171+
- [Vercel部署指南](docs/vercel.md) - Vercel部署详细说明
160172

161173

162174
## Star History
@@ -189,6 +201,7 @@ pnpm dev:fresh # 完整重置并重新启动开发环境
189201
- 或自行部署到Vercel平台
190202
- 在模型设置中勾选"使用Vercel代理"选项
191203
- 请求流向:浏览器→Vercel→模型服务提供商
204+
- 详细步骤请参考 [Vercel部署指南](docs/vercel.md)
192205

193206
2. **使用自部署的API中转服务**(可靠方案)
194207
- 部署如OneAPI等开源API聚合/代理工具

README_EN.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
![GitHub forks](https://img.shields.io/github/forks/linshenkx/prompt-optimizer?style=flat)
1313
[![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)
1414

15-
[Live Demo](https://prompt.always200.com) | [Quick Start](#quick-start) | [FAQ](#faq) | [Development Docs](dev.md) | [Chrome Extension](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna)
15+
[Live Demo](https://prompt.always200.com) | [Quick Start](#quick-start) | [FAQ](#faq) | [Development Docs](dev.md) | [Vercel Deployment Guide](docs/vercel_en.md) | [Chrome Extension](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna)
1616

1717
</div>
1818

@@ -41,15 +41,26 @@ Prompt Optimizer is a powerful AI prompt optimization tool that helps you write
4141

4242
### 1. Use Online Version (Recommended)
4343

44-
1. Direct access: [https://prompt.always200.com](https://prompt.always200.com)
45-
2. Or one-click deploy to your own Vercel:
44+
Direct access: [https://prompt.always200.com](https://prompt.always200.com)
45+
46+
This is a pure frontend project with all data stored locally in your browser and never uploaded to any server, making the online version both safe and reliable to use.
47+
48+
### 2. Vercel Deployment
49+
1. One-click deployment to your own Vercel:
4650
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flinshenkx%2Fprompt-optimizer)
4751

48-
### 2. Install Chrome Extension
52+
2. Fork the project and import to Vercel (Recommended):
53+
- First fork the project to your GitHub account
54+
- Then import the project to Vercel
55+
- This allows tracking of source project updates for easy syncing of new features and fixes
56+
57+
For more detailed deployment steps and important notes, please check the [Vercel Deployment Guide](docs/vercel_en.md)
58+
59+
### 3. Install Chrome Extension
4960
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)
5061
2. Click the icon to open the Prompt Optimizer
5162

52-
### 3. Docker Deployment
63+
### 4. Docker Deployment
5364
```bash
5465
# Run container (default configuration)
5566
docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer linshen/prompt-optimizer
@@ -62,7 +73,7 @@ docker run -d -p 80:80 \
6273
linshen/prompt-optimizer
6374
```
6475

65-
### 4. Docker Compose Deployment
76+
### 5. Docker Compose Deployment
6677
```bash
6778
# 1. Clone the repository
6879
git clone https://github.com/linshenkx/prompt-optimizer.git
@@ -157,6 +168,7 @@ For detailed project status, see [Project Status Document](docs/project-status.m
157168
- [Project Structure](docs/project-structure.md) - Detailed project structure description
158169
- [Project Status](docs/project-status.md) - Current progress and plans
159170
- [Product Requirements](docs/prd.md) - Product requirements document
171+
- [Vercel Deployment Guide](docs/vercel_en.md) - Detailed instructions for Vercel deployment
160172

161173
## Star History
162174

@@ -188,6 +200,7 @@ For detailed project status, see [Project Status Document](docs/project-status.m
188200
- Or deploy to your own Vercel platform
189201
- Check "Use Vercel Proxy" option in model settings
190202
- Request flow: Browser → Vercel → Model service provider
203+
- For detailed steps, please refer to the [Vercel Deployment Guide](docs/vercel_en.md)
191204

192205
2. **Use self-deployed API proxy service** (Reliable solution)
193206
- Deploy open-source API aggregation/proxy tools like OneAPI

docs/vercel.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
## Vercel 部署说明
2+
3+
### 部署方式对比
4+
5+
| 部署方式 | 优点 | 缺点 |
6+
|---------|------|------|
7+
| 一键部署 | 快速简便,无需额外设置 | 无法自动同步源项目更新 |
8+
| Fork后导入 | 可跟踪源项目更新,更易维护 | 第一次部署需要手动修复根目录设置以启用Vercel代理功能 |
9+
10+
### 推荐方式:Fork项目后导入到Vercel(推荐)
11+
12+
这种方式可以让你跟踪项目更新,便于后续同步最新功能和bug修复。
13+
14+
1. **Fork项目到自己的GitHub**
15+
- 访问[prompt-optimizer项目](https://github.com/linshenkx/prompt-optimizer)
16+
- 点击右上角的"Fork"按钮
17+
- 完成fork操作后,你将在自己的GitHub账号下拥有此项目的副本
18+
19+
2. **导入项目到Vercel**
20+
- 登录[Vercel平台](https://vercel.com/)
21+
- 点击"Add New..."→"Project"
22+
- 在"Import Git Repository"部分找到你fork的项目并点击"Import"
23+
- 配置项目(**注意**:此处虽然可以设置根目录,但对多模块项目无效,仍需后续手动修复)
24+
- 点击"Deploy"开始部署
25+
26+
![导入项目到Vercel](../images/vercel/import.png)
27+
28+
3. **修复根目录设置(强烈建议)**
29+
- 通过导入部署时,虽然项目的`vercel.json`文件已包含相关修复可以让基本功能正常工作
30+
- 但若要启用**Vercel代理功能**(解决跨域问题的关键功能),则需手动修复根目录:
31+
32+
a. 在项目部署完成后,进入项目设置
33+
34+
b. 点击左侧菜单中的"Build and Deployment"
35+
36+
c. 在"Root Directory"部分,将输入框中的内容**清空**
37+
38+
d. 点击"Save"保存设置
39+
40+
![清空根目录设置](../images/vercel/setting.png)
41+
42+
4. **重新部署项目**
43+
- 设置保存后,需要手动触发重新部署以使修复生效
44+
- 点击顶部导航栏中的"Deployments"
45+
- 在最新的部署记录右侧,点击"..."按钮
46+
- 选择"Redeploy"选项触发重新部署
47+
48+
![重新部署项目](../images/vercel/redeploy.png)
49+
50+
5. **配置环境变量(可选)**
51+
- 部署完成后,进入项目设置
52+
- 点击"Environment Variables"
53+
- 添加需要的API密钥(例如`VITE_OPENAI_API_KEY`
54+
- 重新部署项目使环境变量生效
55+
56+
6. **同步上游更新**
57+
- 在GitHub上打开你fork的项目
58+
- 如果有更新,会显示"This branch is X commits behind linshenkx:main"
59+
- 点击"Sync fork"按钮同步最新更改
60+
- Vercel会自动检测到代码变更并重新部署
61+
62+
### 替代方式:一键部署到Vercel
63+
64+
如果你只需要快速部署而不关心后续更新,可以使用一键部署方式:
65+
66+
1. 点击以下按钮直接部署到Vercel
67+
[![部署到 Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flinshenkx%2Fprompt-optimizer)
68+
69+
2. 按照Vercel的引导完成部署流程
70+
71+
**优势:** 一键部署方式Vercel能自动正确识别根目录,无需手动修复,所有功能(包括Vercel代理)均可正常使用。
72+
73+
### 关于Vercel代理功能
74+
75+
Prompt Optimizer在Vercel部署时支持使用Edge Runtime代理解决跨域问题。
76+
77+
1. **确认代理功能可用**
78+
- 如使用一键部署:代理功能应直接可用
79+
- 如使用导入部署:需完成上述"修复根目录设置"和"重新部署"步骤
80+
- 在应用中打开"模型管理"
81+
- 选择目标模型->"编辑",此时应该可以看到"使用Vercel代理"选项
82+
- 如果没有看到此选项,说明Vercel Function未正确部署,请检查根目录设置
83+
84+
2. **启用代理功能**
85+
- 勾选"使用Vercel代理"选项
86+
- 保存配置
87+
88+
3. **代理原理**
89+
- 请求流向:浏览器→Vercel Edge Runtime→模型服务提供商
90+
- 解决了浏览器直接访问API时的跨域限制
91+
- 代理功能基于Vercel Function实现,依赖于`/api`路径
92+
93+
4. **注意事项**
94+
- 部分模型服务提供商可能会限制来自Vercel的请求
95+
- 如遇限制,建议使用自部署的API中转服务
96+
97+
### 常见问题
98+
99+
1. **部署后页面空白或报错**
100+
- 检查是否正确配置了环境变量
101+
- 查看Vercel部署日志寻找错误原因
102+
103+
2. **无法连接到模型API**
104+
- 确认API密钥已正确配置
105+
- 尝试启用Vercel代理功能
106+
- 检查模型服务提供商是否限制了Vercel请求
107+
108+
3. **"使用Vercel代理"选项未显示**
109+
- 如使用导入部署:检查是否已清空根目录设置并重新部署
110+
- 验证`/api/vercel-status`路径是否可访问(可通过浏览器访问`你的域名/api/vercel-status`测试)
111+
- 查看部署日志中是否有关于Function的错误信息
112+
113+
4. **如何更新已部署的项目**
114+
- 如果是fork后导入:同步fork并等待自动部署
115+
- 如果是一键部署:需要重新部署新版本(无法自动跟踪源项目更新)
116+
117+
5. **如何添加自定义域名**
118+
- 在Vercel项目设置中选择"Domains"
119+
- 添加并验证你的域名
120+
- 按照指引配置DNS记录

docs/vercel_en.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
## Vercel Deployment Guide
2+
3+
### Deployment Method Comparison
4+
5+
| Deployment Method | Advantages | Disadvantages |
6+
|---------|------|------|
7+
| One-click Deployment | Quick and convenient, no additional setup required | Cannot automatically sync updates from the source project |
8+
| Fork and Import | Can track source project updates, easier to maintain | First deployment requires manual root directory fix to enable Vercel proxy functionality |
9+
10+
### Recommended Method: Fork the Project and Import to Vercel (Recommended)
11+
12+
This method allows you to track project updates, making it easier to sync the latest features and bug fixes.
13+
14+
1. **Fork the project to your GitHub account**
15+
- Visit the [prompt-optimizer project](https://github.com/linshenkx/prompt-optimizer)
16+
- Click the "Fork" button in the top right corner
17+
- After completing the fork operation, you will have a copy of this project under your GitHub account
18+
19+
2. **Import the project to Vercel**
20+
- Log in to the [Vercel platform](https://vercel.com/)
21+
- Click "Add New..." → "Project"
22+
- Find your forked project in the "Import Git Repository" section and click "Import"
23+
- Configure the project (**Note**: Although you can set the root directory here, it is ineffective for multi-module projects and will still require manual fixing later)
24+
- Click "Deploy" to start deployment
25+
26+
![Import project to Vercel](../images/vercel/import.png)
27+
28+
3. **Fix the root directory setting (Strongly recommended)**
29+
- When deployed through import, although the project's `vercel.json` file already contains related fixes to make basic functionality work
30+
- To enable **Vercel proxy functionality** (a key feature for solving cross-origin issues), you need to manually fix the root directory:
31+
32+
a. After the project is deployed, go to project settings
33+
34+
b. Click "Build and Deployment" in the left menu
35+
36+
c. In the "Root Directory" section, **clear** the content in the input box
37+
38+
d. Click "Save" to save the settings
39+
40+
![Clear root directory setting](../images/vercel/setting.png)
41+
42+
4. **Redeploy the project**
43+
- After saving the settings, you need to manually trigger a redeployment to make the fix effective
44+
- Click "Deployments" in the top navigation bar
45+
- On the right side of the latest deployment record, click the "..." button
46+
- Select the "Redeploy" option to trigger redeployment
47+
48+
![Redeploy the project](../images/vercel/redeploy.png)
49+
50+
5. **Configure environment variables (Optional)**
51+
- After deployment is complete, go to project settings
52+
- Click "Environment Variables"
53+
- Add the required API keys (e.g., `VITE_OPENAI_API_KEY`)
54+
- Redeploy the project to make the environment variables effective
55+
56+
6. **Sync upstream updates**
57+
- Open your forked project on GitHub
58+
- If there are updates, it will show "This branch is X commits behind linshenkx:main"
59+
- Click the "Sync fork" button to sync the latest changes
60+
- Vercel will automatically detect code changes and redeploy
61+
62+
### Alternative Method: One-click Deployment to Vercel
63+
64+
If you only need quick deployment and don't care about subsequent updates, you can use the one-click deployment method:
65+
66+
1. Click the button below to deploy directly to Vercel
67+
[![Deploy to Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flinshenkx%2Fprompt-optimizer)
68+
69+
2. Follow Vercel's guidance to complete the deployment process
70+
71+
**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.
72+
73+
### About Vercel Proxy Functionality
74+
75+
Prompt Optimizer supports using Edge Runtime proxy to solve cross-origin issues when deployed on Vercel.
76+
77+
1. **Confirm proxy functionality is available**
78+
- If using one-click deployment: proxy functionality should be directly available
79+
- If using import deployment: you need to complete the "Fix root directory setting" and "Redeploy" steps mentioned above
80+
- Open "Model Management" in the application
81+
- Select the target model -> "Edit", at this point you should see the "Use Vercel Proxy" option
82+
- If you don't see this option, it means the Vercel Function is not correctly deployed, please check the root directory setting
83+
84+
2. **Enable proxy functionality**
85+
- Check the "Use Vercel Proxy" option
86+
- Save the configuration
87+
88+
3. **Proxy principle**
89+
- Request flow: Browser → Vercel Edge Runtime → Model service provider
90+
- Solves the cross-origin limitation when browsers directly access APIs
91+
- Proxy functionality is based on Vercel Function implementation, dependent on the `/api` path
92+
93+
4. **Notes**
94+
- Some model service providers may restrict requests from Vercel
95+
- If restrictions are encountered, it is recommended to use a self-deployed API relay service
96+
97+
### Common Issues
98+
99+
1. **Blank page or error after deployment**
100+
- Check if environment variables are correctly configured
101+
- View Vercel deployment logs to find the cause of errors
102+
103+
2. **Cannot connect to model API**
104+
- Confirm the API key is correctly configured
105+
- Try enabling Vercel proxy functionality
106+
- Check if the model service provider restricts Vercel requests
107+
108+
3. **"Use Vercel Proxy" option not displayed**
109+
- If using import deployment: check if you have cleared the root directory setting and redeployed
110+
- Verify if the `/api/vercel-status` path is accessible (you can test by visiting `your-domain/api/vercel-status` in a browser)
111+
- Check if there are any Function-related error messages in the deployment logs
112+
113+
4. **How to update a deployed project**
114+
- If forked and imported: sync the fork and wait for automatic deployment
115+
- If one-click deployed: need to redeploy the new version (cannot automatically track source project updates)
116+
117+
5. **How to add a custom domain**
118+
- Select "Domains" in the Vercel project settings
119+
- Add and verify your domain
120+
- Follow the guidance to configure DNS records

images/vercel/import.png

67.8 KB
Loading

images/vercel/redeploy.png

114 KB
Loading

images/vercel/setting.png

150 KB
Loading

0 commit comments

Comments
 (0)