Skip to content

反向代理子路径支持实现 - #1087

Open
yomiel-s wants to merge 10 commits into
EstrellaXD:3.3-devfrom
yomiel-s:feat/subpath-support
Open

反向代理子路径支持实现#1087
yomiel-s wants to merge 10 commits into
EstrellaXD:3.3-devfrom
yomiel-s:feat/subpath-support

Conversation

@yomiel-s

Copy link
Copy Markdown

概述

通过 AB_ROOT_PATH 环境变量实现运行时动态 base path,支持 nginx/traefik 反向代理子路径部署。

改动文件

文件 改动
backend/src/main.py 读取并归一化 AB_ROOT_PATH,FastAPI root_path,Jinja2 注入,PWA manifest 动态路由
webui/index.html /images//fonts/ 绝对路径改用 {{ base_path }} 前缀
webui/vite.config.ts Vite dev 插件:dev 模式替换 Jinja2 占位符
webui/src/utils/base-path.ts 新增 basePath() 工具函数
webui/src/utils/poster.ts 海报 URL 基于 __BASE_PATH__ 拼接
webui/src/components/layout/ab-topbar.vue Logo 图片适配 base path
webui/src/pages/login.vue Logo 图片适配 base path
webui/types/dts/vite-env.d.ts Window.__BASE_PATH__ 类型声明

使用方式

docker run -e AB_ROOT_PATH=/bangumi auto_bangumi
nginx 配置:
location /bangumi/ {
    proxy_pass http://127.0.0.1:7892/;
}

不设置 AB_ROOT_PATH 时行为与旧版完全兼容。

测试

  • 前端:pnpm test:build 通过,pnpm build 通过
  • 手动验证:无 AB_ROOT_PATH 时正常运行;设置后所有资源路径正确拼接

RFC Issue: 反向代理子路径支持

EstrellaXD and others added 7 commits July 13, 2026 20:37
- index.html: use Jinja2 {{ base_path }} for /images/ and /fonts/ URLs
- vite.config.ts: dev plugin replaces all {{ base_path }} occurrences
- new base-path.ts utility function
- ab-topbar.vue, login.vue: use basePath() for image src
- main.py: dynamic PWA manifest route with base path injection
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

@yomiel-s is attempting to deploy a commit to the estrellaxd's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants