fix: 修复相册缩略图无法显示(dev 代理 + 前端兜底)
- vite: /uploads 代理指向源站根而非 /apnew 前缀,relative thumbnailUrl (/uploads/thumb…) 在 dev 下不再落到 SPA index.html - BubbleImage: 新增 fallbackSrc 候选链,缩略图加载失败时自动回退到绝对 thumbUrl/url,全部失败才显示占位符 - AlbumBubble / ImageLightbox: 缩略图传入绝对地址作为兜底 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,17 @@ import react from "@vitejs/plugin-react";
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
const apiProxyTarget = env.DEV_API_PROXY_TARGET || "http://127.0.0.1:8080";
|
||||
// Uploaded assets (thumbnails etc.) are served from the site root, NOT under
|
||||
// the API's /apnew prefix. Proxy /uploads to the origin root so relative
|
||||
// thumbnailUrls like "/uploads/thumb52-….jpg" resolve to a real image in dev
|
||||
// instead of falling through to the SPA's index.html.
|
||||
const uploadsProxyTarget = (() => {
|
||||
try {
|
||||
return new URL(apiProxyTarget).origin;
|
||||
} catch {
|
||||
return apiProxyTarget;
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
plugins: [react()],
|
||||
@@ -26,7 +37,7 @@ export default defineConfig(({ mode }) => {
|
||||
rewrite: (path) => path.replace(/^\/apnew/, ""),
|
||||
},
|
||||
"/api": { target: apiProxyTarget, changeOrigin: true },
|
||||
"/uploads": { target: apiProxyTarget, changeOrigin: true },
|
||||
"/uploads": { target: uploadsProxyTarget, changeOrigin: true },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user