chore(proxy): expose backend under /admin139 on frontend port
这个提交包含在:
3
.env
3
.env
@@ -10,7 +10,8 @@ CSP_SEED_ADMIN_USERNAME=admin
|
||||
CSP_SEED_ADMIN_PASSWORD=whoami139
|
||||
|
||||
# 前端请求后端的地址(浏览器侧)
|
||||
NEXT_PUBLIC_API_BASE=http://localhost:8080
|
||||
# 使用同域反代访问后端(通过Next.js)
|
||||
NEXT_PUBLIC_API_BASE=/admin139
|
||||
|
||||
# Next.js 服务端反代用(可选)
|
||||
BACKEND_INTERNAL_URL=http://backend:8080
|
||||
|
||||
@@ -5,8 +5,9 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.backend
|
||||
ports:
|
||||
- "8080:8080"
|
||||
# 如需直连后端调试,可打开端口映射;默认仅通过前端反代访问
|
||||
# ports:
|
||||
# - "8080:8080"
|
||||
volumes:
|
||||
- csp_data:/data
|
||||
restart: unless-stopped
|
||||
@@ -18,8 +19,8 @@ services:
|
||||
context: .
|
||||
dockerfile: Dockerfile.frontend
|
||||
environment:
|
||||
# 浏览器侧请求后端的公共地址(本机测试用 localhost)
|
||||
- NEXT_PUBLIC_API_BASE=http://localhost:8080
|
||||
# 浏览器侧通过同域路径前缀访问后端(Next.js反代到backend)
|
||||
- NEXT_PUBLIC_API_BASE=/admin139
|
||||
# Next.js 服务端反代用(可选),仅在你把 NEXT_PUBLIC_API_BASE 设为 /api 时需要
|
||||
- BACKEND_INTERNAL_URL=http://backend:8080
|
||||
ports:
|
||||
|
||||
@@ -8,10 +8,10 @@ docker compose up -d --build
|
||||
|
||||
## 访问
|
||||
|
||||
- 后端(健康检查):http://localhost:8080/api/health
|
||||
- 后端(注册):`POST http://localhost:8080/api/v1/auth/register`
|
||||
- 后端(登录):`POST http://localhost:8080/api/v1/auth/login`
|
||||
- 前端:http://localhost:7888
|
||||
- 后端(通过前端反代):http://localhost:7888/admin139/api/health
|
||||
- 后端(注册):`POST http://localhost:7888/admin139/api/v1/auth/register`
|
||||
- 后端(登录):`POST http://localhost:7888/admin139/api/v1/auth/login`
|
||||
|
||||
## 数据持久化
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@ const nextConfig: NextConfig = {
|
||||
// For local dev convenience. In production you should configure reverse proxy
|
||||
// and set NEXT_PUBLIC_API_BASE to your public API origin.
|
||||
async rewrites() {
|
||||
// If the user sets NEXT_PUBLIC_API_BASE to "/api", we can proxy to backend
|
||||
// from the Next.js server (SSR). This does NOT affect browser fetch.
|
||||
// Reverse proxy backend under a path prefix, so browser can access backend
|
||||
// with same-origin (no CORS): http://<host>:7888/admin139/...
|
||||
const backendInternal = process.env.BACKEND_INTERNAL_URL;
|
||||
if (!backendInternal) return [];
|
||||
|
||||
return [
|
||||
{
|
||||
source: "/api/:path*",
|
||||
destination: `${backendInternal}/api/:path*`,
|
||||
source: "/admin139/:path*",
|
||||
destination: `${backendInternal}/:path*`,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
在新工单中引用
屏蔽一个用户