fix: use same-origin media proxy in local development
This commit is contained in:
1 parent
441b55d25b
commit
dff7261f80
2 files changed
+3
-2
No files matched your search
+2
-1
@@ -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=
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user