diff --git a/.env.example b/.env.example index 2cd2e46..8fa0799 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ # Author: fruit.com.cn VITE_API_BASE_URL=http://127.0.0.1:8081 -VITE_MEDIA_BASE_URL=http://127.0.0.1:8081 +# Leave empty in local development so Vite proxies /files without CORS issues. +VITE_MEDIA_BASE_URL= diff --git a/src/services/normalizers.js b/src/services/normalizers.js index 955d2d4..0d6ad18 100644 --- a/src/services/normalizers.js +++ b/src/services/normalizers.js @@ -1,6 +1,6 @@ // Author: fruit.com.cn const FALLBACK_IMAGE = '/assets/hero.jpg'; -const MEDIA_BASE_URL = (import.meta.env.VITE_MEDIA_BASE_URL || 'http://127.0.0.1:8081').replace(/\/$/, ''); +const MEDIA_BASE_URL = (import.meta.env.VITE_MEDIA_BASE_URL || '').replace(/\/$/, ''); const getText = (value, lang = 'id') => (typeof value === 'string' ? value : value?.[lang] || value?.en || value?.id || value?.zh || ''); const resolveMedia = (value) => value ? (/^https?:\/\//.test(value) ? value : `${MEDIA_BASE_URL}${value}`) : FALLBACK_IMAGE; const getImage = (item) => resolveMedia(item.coverLandscape || item.coverUrl || item.cover || item.posterUrl || item.imageUrl);