修改主机地址
This commit is contained in:
21
.env
Normal file
21
.env
Normal file
@@ -0,0 +1,21 @@
|
||||
# 数据库配置
|
||||
DB_HOST=localhost
|
||||
DB_PORT=33306
|
||||
DB_USER=root
|
||||
DB_PASSWORD=123456
|
||||
DB_NAME=employee_performance
|
||||
|
||||
# JWT 配置
|
||||
JWT_SECRET=dev_jwt_secret_please_change_in_production
|
||||
|
||||
# FastGPT API 配置
|
||||
FASTGPT_API_KEY=fastgpt-oEipxYa5BfVaeGDj74iAXi8YSkWyye07lTNYuj7yydsEKAc4Hp2Z2RDbxsxc4TuZ
|
||||
FASTGPT_API_URL=https://cloud.fastgpt.cn/api/v1/chat/completions
|
||||
FASTGPT_MODEL=gpt-4
|
||||
|
||||
# 代理配置(Node.js 不自动读取系统代理,需手动配置)
|
||||
HTTPS_PROXY=http://127.0.0.1:7890
|
||||
|
||||
# 服务器配置
|
||||
PORT=3001
|
||||
NODE_ENV=development
|
||||
27
backend/.env.production.example
Normal file
27
backend/.env.production.example
Normal file
@@ -0,0 +1,27 @@
|
||||
# 生产环境配置示例
|
||||
# 根据您的部署方式调整以下配置
|
||||
|
||||
# 数据库配置
|
||||
# Docker Compose 部署:DB_HOST=db, DB_PORT=3306 (容器内部)
|
||||
# 传统部署(数据库在本地):DB_HOST=localhost, DB_PORT=3306
|
||||
# 传统部署(数据库在远程服务器):DB_HOST=数据库服务器IP, DB_PORT=3306
|
||||
DB_HOST=localhost
|
||||
DB_PORT=3306
|
||||
DB_USER=root
|
||||
DB_PASSWORD=your_secure_password_here
|
||||
DB_NAME=employee_performance
|
||||
|
||||
# JWT 配置(生产环境必须使用强密钥)
|
||||
JWT_SECRET=generate_a_strong_random_string_at_least_32_chars_long
|
||||
|
||||
# FastGPT API 配置
|
||||
FASTGPT_API_KEY=your_fastgpt_api_key_here
|
||||
FASTGPT_API_URL=https://api.fastgpt.in/api/v1/chat/completions
|
||||
FASTGPT_MODEL=gpt-4
|
||||
|
||||
# 代理配置(如果需要通过代理访问 FastGPT)
|
||||
# HTTPS_PROXY=http://127.0.0.1:7890
|
||||
|
||||
# 服务器配置
|
||||
PORT=3001
|
||||
NODE_ENV=production
|
||||
@@ -26,7 +26,7 @@ async function run() {
|
||||
{ expiresIn: '1h' }
|
||||
);
|
||||
|
||||
const { data } = await axios.get('http://localhost:3001/api/performance/employee/get', {
|
||||
const { data } = await axios.get('http://47.238.126.111:33001/api/performance/employee/get', {
|
||||
params: { perfId: rec.perf_id },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ services:
|
||||
MYSQL_USER: app_user
|
||||
MYSQL_PASSWORD: app_password
|
||||
ports:
|
||||
- "3306:3306"
|
||||
- "33306:3306"
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
- ./backend/src/db/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
@@ -52,7 +52,7 @@ services:
|
||||
PORT: 3001
|
||||
NODE_ENV: development
|
||||
ports:
|
||||
- "3001:3001"
|
||||
- "33001:3001"
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
- /app/node_modules
|
||||
@@ -75,9 +75,10 @@ services:
|
||||
depends_on:
|
||||
- backend
|
||||
environment:
|
||||
VITE_API_BASE_URL: http://47.238.126.111:33001
|
||||
VITE_API_URL: http://backend:3001
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "2000:3000"
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
- /app/node_modules
|
||||
|
||||
11
frontend/.env.production.example
Normal file
11
frontend/.env.production.example
Normal file
@@ -0,0 +1,11 @@
|
||||
# 前端生产环境配置
|
||||
# 构建时使用的环境变量
|
||||
|
||||
# API 基础 URL
|
||||
# Docker Compose 部署(前端独立构建,后端在 47.238.126.111:33001):
|
||||
VITE_API_BASE_URL=http://47.238.126.111:33001
|
||||
|
||||
# 传统部署(Nginx 反向代理):
|
||||
# VITE_API_BASE_URL=/api # 如果使用 Nginx 反向代理到后端,可以设置为相对路径 /api
|
||||
|
||||
# 其他环境变量可根据需要添加
|
||||
@@ -3,7 +3,7 @@ import axios from 'axios';
|
||||
const TOKEN_KEY = 'auth_token';
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:3001',
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:33001',
|
||||
timeout: 15000,
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export default defineConfig({
|
||||
port: 3000,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: process.env.VITE_API_URL || 'http://localhost:3001',
|
||||
target: process.env.VITE_API_URL || 'http://localhost:33001',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
||||
1
tmpclaude-490d-cwd
Normal file
1
tmpclaude-490d-cwd
Normal file
@@ -0,0 +1 @@
|
||||
/c/Users/99095/Desktop/优一科技/performance-evaluation-system
|
||||
1
tmpclaude-8604-cwd
Normal file
1
tmpclaude-8604-cwd
Normal file
@@ -0,0 +1 @@
|
||||
/c/Users/99095/Desktop/优一科技/performance-evaluation-system
|
||||
1
tmpclaude-b5ce-cwd
Normal file
1
tmpclaude-b5ce-cwd
Normal file
@@ -0,0 +1 @@
|
||||
/c/Users/99095/Desktop/优一科技/performance-evaluation-system
|
||||
1
tmpclaude-e9ac-cwd
Normal file
1
tmpclaude-e9ac-cwd
Normal file
@@ -0,0 +1 @@
|
||||
/c/Users/99095/Desktop/优一科技/performance-evaluation-system
|
||||
1
tmpclaude-eb3d-cwd
Normal file
1
tmpclaude-eb3d-cwd
Normal file
@@ -0,0 +1 @@
|
||||
/c/Users/99095/Desktop/优一科技/performance-evaluation-system
|
||||
10
部署文档.md
10
部署文档.md
@@ -81,7 +81,7 @@ cp .env.example .env
|
||||
```env
|
||||
# 数据库配置
|
||||
DB_HOST=localhost
|
||||
DB_PORT=3306
|
||||
DB_PORT=33306 # Docker Compose 部署时使用 33306,传统部署请根据实际情况调整
|
||||
DB_USER=perf_user
|
||||
DB_PASSWORD=你的数据库密码
|
||||
DB_NAME=employee_performance
|
||||
@@ -158,7 +158,7 @@ npm install
|
||||
|
||||
```typescript
|
||||
const http = axios.create({
|
||||
baseURL: 'http://你的后端服务器IP:3001',
|
||||
baseURL: 'http://47.238.126.111:33001', # Docker Compose 部署时使用 33001,传统部署使用 3001
|
||||
timeout: 15000,
|
||||
});
|
||||
```
|
||||
@@ -166,7 +166,7 @@ const http = axios.create({
|
||||
或者通过环境变量配置,在 `frontend/` 目录创建 `.env.production`:
|
||||
|
||||
```env
|
||||
VITE_API_BASE_URL=http://你的后端服务器IP:3001
|
||||
VITE_API_BASE_URL=http://47.238.126.111:33001 # Docker Compose 部署时使用 33001,传统部署使用 3001
|
||||
```
|
||||
|
||||
### 5.3 构建静态文件
|
||||
@@ -184,7 +184,7 @@ npm run build
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name 你的域名或IP;
|
||||
server_name 47.238.126.111;
|
||||
|
||||
# 前端静态文件
|
||||
root /var/www/perf-system/dist;
|
||||
@@ -197,7 +197,7 @@ server {
|
||||
|
||||
# 反向代理后端 API
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:3001;
|
||||
proxy_pass http://127.0.0.1:33001; # Docker Compose 部署时使用 33001,传统部署使用 3001
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user