fix(theme): appearance 走同源 ctx 前缀,不被跨源跳过
deploy-bschclass-front / build-and-deploy (push) Failing after 3m2s
build / build (push) Successful in 3m24s

主题通道 yh-theme-init.js 的 appearance 有硬性同源限制
(appearanceSameOrigin 不通过直接 return,连请求都不发)。

- host.config.ts:仅当最终 serviceUrl 与当前页面同源时,才回写
  __APP_CONFIG__.serviceHost;dev 的绝对地址(跨源)不回写,保持
  '/api/appearance' 同源相对,交由 vite 代理转发,避免被整段跳过。
- prod:serviceUrl = 同域 ctx(https://base.../userclass),回写后
  appearance 命中 https://base.../userclass/api/appearance。
- vite.config.ts:/api 代理支持 YH_API_PROXY_TARGET 指向真实后端
  (target 带 /userclass 前缀即可,无需 rewrite)。
This commit is contained in:
lijing
2026-10-20 15:16:55 +08:00
parent 542002bb85
commit c2a1f16915
2 changed files with 29 additions and 0 deletions
+3
View File
@@ -43,6 +43,9 @@ export default defineConfig(({ mode }) => {
open: false,
proxy: {
// 本地后端:serviceUrl 在 dev 下为空 → /api/* 同源相对,由本代理转发
// 想直接连真实后端(含主题通道「同源」的 appearance):
// YH_API_PROXY_TARGET=http://base.yunhaixingtong.com/userclass npm run dev
// 注意 target 要带上下文前缀 /userclass,http-proxy 会把它拼在 /api 前
"/api": {
target: process.env.YH_API_PROXY_TARGET || "http://localhost:8101",
changeOrigin: true,