Skip to content

Commit 719e0f2

Browse files
committed
YUNYU_API_BASE_INTERNAL改造验证2
1 parent 65c5da8 commit 719e0f2

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

docker/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ SERVER_PORT=20000
2121
YUNYU_WEB_IMAGE=ghcr.io/idea-flow/yunyu-web:latest
2222
# SSR 服务端调用后端的内部地址(容器内网),默认已指向 yunyu-server-native:20000,通常无需修改
2323
# 仅在自定义容器名或网络时才需要覆盖
24-
YUNYU_API_BASE_INTERNAL=http://yunyu-server-native:20000
24+
NUXT_YUNYU_API_BASE_INTERNAL=http://yunyu-server-native:20000
2525
# 浏览器端 API 地址:纯 Docker 模式下前后端同域,浏览器通过 nginx 转发 /api/*,留空即可
2626
# 若需要跨域访问后端,填写后端完整域名,如:https://api.yourdomain.com
2727
YUNYU_PUBLIC_API_BASE=

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ services:
5353
- yunyu-server-native
5454
environment:
5555
# SSR 服务端调用后端使用容器名(内部网络),浏览器端 API 请求经 nginx 同域转发,无需单独配置
56-
YUNYU_API_BASE_INTERNAL: ${YUNYU_API_BASE_INTERNAL:-http://yunyu-server-native:20000}
56+
NUXT_YUNYU_API_BASE_INTERNAL: ${NUXT_YUNYU_API_BASE_INTERNAL:-http://yunyu-server-native:20000}
5757
NUXT_PUBLIC_API_BASE: ${YUNYU_PUBLIC_API_BASE:-}
5858
TZ: ${TZ:-Asia/Shanghai}
5959
# 不对外暴露端口,只在内部网络中被 nginx 访问

yunyu-web/app/composables/useApiClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export function useApiClient() {
2828
* SSR 阶段优先使用容器内网地址(apiBaseInternal),浏览器端使用 public.apiBase(留空则走 nginx 同域转发)。
2929
*/
3030
function resolveApiBase() {
31-
if (import.meta.server && config.apiBaseInternal) {
32-
return config.apiBaseInternal
31+
if (import.meta.server && config.yunyuApiBaseInternal) {
32+
return config.yunyuApiBaseInternal
3333
}
3434
return config.public.apiBase
3535
}

yunyu-web/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default defineNuxtConfig({
2222
css: ['katex/dist/katex.min.css', '~/assets/css/main.css'],
2323
runtimeConfig: {
2424
// 仅服务端可见:SSR 阶段调用后端使用容器内部地址,避免走 nginx 或公网
25-
apiBaseInternal: process.env.YUNYU_API_BASE_INTERNAL || '',
25+
yunyuApiBaseInternal: process.env.NUXT_YUNYU_API_BASE_INTERNAL || '',
2626
public: {
2727
// 浏览器端使用:留空时请求走相对路径,由 nginx 同域转发到后端
2828
apiBase: process.env.YUNYU_PUBLIC_API_BASE || ''

yunyu-web/server/api/web/debug-config.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
export default defineEventHandler((event) => {
66
const config = useRuntimeConfig(event)
77

8-
const apiBaseInternal = config.apiBaseInternal || ''
8+
const apiBaseInternal = config.yunyuApiBaseInternal || ''
99
const apiBasePublic = config.public.apiBase || ''
1010
const resolvedApiBase = apiBaseInternal || apiBasePublic
1111

0 commit comments

Comments
 (0)