fix(theme): appearance 走同源 ctx 前缀,不被跨源跳过
主题通道 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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user