Commit 918a2844 by luoqi

merge: fix/docs-api-url → main(docs OpenAPI 地址随环境)

parents bda06ca4 ab0f7101
Pipeline #3537 failed in 0 seconds
......@@ -45,3 +45,14 @@ describe('docker-compose.prod.yml 日志驱动', () => {
expect(compose.services['pac-asr']!.profiles).toContain('asr');
});
});
describe('docs OpenAPI server 地址', () => {
test('⭐ 不硬编码域名 —— 这份 compose 测试服与生产共用,写死会让生产 docs 打到测试服', () => {
const args = (compose.services['pac-docs'] as { build?: { args?: Record<string, string> } }).build?.args ?? {};
const v = args['DOCS_API_URL'] ?? '';
expect(v).toMatch(/^\$\{/); // 必须是变量插值
expect(v).not.toMatch(/jarvismedical|friday\.tech/); // 不得出现任何具体域名
// 复用 NEXT_PUBLIC_API_BASE_URL:它就是同一个东西,各环境 .env 已有,不会再漂移
expect(v).toContain('NEXT_PUBLIC_API_BASE_URL');
});
});
......@@ -163,8 +163,13 @@ services:
dockerfile: apps/pac-docs/Dockerfile
target: prod
args:
# OpenAPI 参考页 Scalar 的 server 地址(cURL/Send base);本地默认 localhost:3101,线上注入生产域名
DOCS_API_URL: https://pac.jarvismedical.asia
# OpenAPI 参考页 Scalar 的 server 地址(cURL/Send base)。
# ⚠️ 曾硬编码成 https://pac.jarvismedical.asia(测试服域名)—— 而这份 compose 是
# **测试服与生产共用**的,于是生产 docs 页上点"发送请求"会打到测试服去。
# 改为复用 NEXT_PUBLIC_API_BASE_URL:它就是同一个东西(API 的对外地址),
# 各环境 apps/pac-web/.env 里本来就有,零额外配置、且不会再随环境漂移。
# 要单独指定时才设 DOCS_API_URL 覆盖;都没有则退回本地。
DOCS_API_URL: ${DOCS_API_URL:-${NEXT_PUBLIC_API_BASE_URL:-http://localhost:3101}}
restart: always
environment:
NODE_ENV: production
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment