修改主机地址

This commit is contained in:
2026-04-12 11:53:28 +08:00
parent f0cc37681c
commit 0ec92b10a1
13 changed files with 76 additions and 11 deletions

21
.env Normal file
View 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

View 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

View File

@@ -26,7 +26,7 @@ async function run() {
{ expiresIn: '1h' } { 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 }, params: { perfId: rec.perf_id },
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });

View File

@@ -12,7 +12,7 @@ services:
MYSQL_USER: app_user MYSQL_USER: app_user
MYSQL_PASSWORD: app_password MYSQL_PASSWORD: app_password
ports: ports:
- "3306:3306" - "33306:3306"
volumes: volumes:
- mysql_data:/var/lib/mysql - mysql_data:/var/lib/mysql
- ./backend/src/db/init.sql:/docker-entrypoint-initdb.d/init.sql - ./backend/src/db/init.sql:/docker-entrypoint-initdb.d/init.sql
@@ -52,7 +52,7 @@ services:
PORT: 3001 PORT: 3001
NODE_ENV: development NODE_ENV: development
ports: ports:
- "3001:3001" - "33001:3001"
volumes: volumes:
- ./backend:/app - ./backend:/app
- /app/node_modules - /app/node_modules
@@ -75,9 +75,10 @@ services:
depends_on: depends_on:
- backend - backend
environment: environment:
VITE_API_BASE_URL: http://47.238.126.111:33001
VITE_API_URL: http://backend:3001 VITE_API_URL: http://backend:3001
ports: ports:
- "3000:3000" - "2000:3000"
volumes: volumes:
- ./frontend:/app - ./frontend:/app
- /app/node_modules - /app/node_modules

View 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
# 其他环境变量可根据需要添加

View File

@@ -3,7 +3,7 @@ import axios from 'axios';
const TOKEN_KEY = 'auth_token'; const TOKEN_KEY = 'auth_token';
const http = axios.create({ 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, timeout: 15000,
}); });

View File

@@ -7,7 +7,7 @@ export default defineConfig({
port: 3000, port: 3000,
proxy: { proxy: {
'/api': { '/api': {
target: process.env.VITE_API_URL || 'http://localhost:3001', target: process.env.VITE_API_URL || 'http://localhost:33001',
changeOrigin: true, changeOrigin: true,
}, },
}, },

1
tmpclaude-490d-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-8604-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-b5ce-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-e9ac-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-eb3d-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

View File

@@ -81,7 +81,7 @@ cp .env.example .env
```env ```env
# 数据库配置 # 数据库配置
DB_HOST=localhost DB_HOST=localhost
DB_PORT=3306 DB_PORT=33306 # Docker Compose 部署时使用 33306传统部署请根据实际情况调整
DB_USER=perf_user DB_USER=perf_user
DB_PASSWORD=你的数据库密码 DB_PASSWORD=你的数据库密码
DB_NAME=employee_performance DB_NAME=employee_performance
@@ -158,7 +158,7 @@ npm install
```typescript ```typescript
const http = axios.create({ const http = axios.create({
baseURL: 'http://你的后端服务器IP:3001', baseURL: 'http://47.238.126.111:33001', # Docker Compose 部署时使用 33001,传统部署使用 3001
timeout: 15000, timeout: 15000,
}); });
``` ```
@@ -166,7 +166,7 @@ const http = axios.create({
或者通过环境变量配置,在 `frontend/` 目录创建 `.env.production` 或者通过环境变量配置,在 `frontend/` 目录创建 `.env.production`
```env ```env
VITE_API_BASE_URL=http://你的后端服务器IP:3001 VITE_API_BASE_URL=http://47.238.126.111:33001 # Docker Compose 部署时使用 33001传统部署使用 3001
``` ```
### 5.3 构建静态文件 ### 5.3 构建静态文件
@@ -184,7 +184,7 @@ npm run build
```nginx ```nginx
server { server {
listen 80; listen 80;
server_name 你的域名或IP; server_name 47.238.126.111;
# 前端静态文件 # 前端静态文件
root /var/www/perf-system/dist; root /var/www/perf-system/dist;
@@ -197,7 +197,7 @@ server {
# 反向代理后端 API # 反向代理后端 API
location /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 Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;