fix: Use /api/city/assets/proxy/ for asset URLs instead of /api/assets/
- Change normalizeAssetUrl to use working city-service proxy endpoint - This ensures assets work without assets.daarion.space DNS
This commit is contained in:
@@ -12,23 +12,14 @@ export function normalizeAssetUrl(url: string | null | undefined): string | null
|
||||
|
||||
// Full HTTPS/HTTP URLs (from MinIO/S3)
|
||||
if (url.startsWith('http://') || url.startsWith('https://')) {
|
||||
// Convert assets.daarion.space URLs to /api/assets/... proxy
|
||||
// Convert assets.daarion.space URLs to /api/city/assets/proxy/... proxy
|
||||
// This works even if DNS for assets.daarion.space is not configured
|
||||
if (url.includes('assets.daarion.space')) {
|
||||
// Extract path after domain: https://assets.daarion.space/daarion-assets/microdao/logo/...
|
||||
// Convert to: /api/assets/microdao/logo/...
|
||||
const urlObj = new URL(url);
|
||||
const pathParts = urlObj.pathname.split('/').filter(p => p);
|
||||
// Remove bucket name (usually first part)
|
||||
const bucketIndex = pathParts.findIndex(p => p === 'daarion-assets');
|
||||
if (bucketIndex >= 0) {
|
||||
const assetPath = pathParts.slice(bucketIndex + 1).join('/');
|
||||
return `/api/assets/${assetPath}`;
|
||||
}
|
||||
// Fallback: try to extract path after /daarion-assets/
|
||||
// Extract path after /daarion-assets/: https://assets.daarion.space/daarion-assets/microdao/logo/...
|
||||
// Convert to: /api/city/assets/proxy/microdao/logo/...
|
||||
const match = url.match(/\/daarion-assets\/(.+)$/);
|
||||
if (match) {
|
||||
return `/api/assets/${match[1]}`;
|
||||
return `/api/city/assets/proxy/${match[1]}`;
|
||||
}
|
||||
}
|
||||
// For other HTTPS URLs, return as-is
|
||||
|
||||
Reference in New Issue
Block a user