Docker update
This commit is contained in:
@ -72,6 +72,7 @@ class BlogService {
|
|||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
const apiBlogs: ApiBlog[] = await response.json();
|
const apiBlogs: ApiBlog[] = await response.json();
|
||||||
|
console.log('Raw API response:', JSON.stringify(apiBlogs, null, 2));
|
||||||
return this.transformApiBlogsToBlogs(apiBlogs);
|
return this.transformApiBlogsToBlogs(apiBlogs);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching posted blogs:', error);
|
console.error('Error fetching posted blogs:', error);
|
||||||
@ -166,17 +167,23 @@ class BlogService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getImageUrl(imageUrl?: string): string {
|
private getImageUrl(imageUrl?: string): string {
|
||||||
|
// Debug logging
|
||||||
|
console.log('Processing imageUrl:', imageUrl);
|
||||||
|
|
||||||
// Return default if no imageUrl provided
|
// Return default if no imageUrl provided
|
||||||
if (!imageUrl || imageUrl.trim() === '') {
|
if (!imageUrl || imageUrl.trim() === '') {
|
||||||
|
console.log('No imageUrl provided, using default');
|
||||||
return this.getDefaultImage();
|
return this.getDefaultImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Decode if the URL is encoded
|
// Decode if the URL is encoded
|
||||||
const decodedUrl = imageUrl.includes('%') ? decodeURIComponent(imageUrl) : imageUrl;
|
const decodedUrl = imageUrl.includes('%') ? decodeURIComponent(imageUrl) : imageUrl;
|
||||||
|
console.log('Decoded URL:', decodedUrl);
|
||||||
|
|
||||||
// If it's already a complete URL, return as is
|
// If it's already a complete URL, return as is
|
||||||
if (decodedUrl.startsWith('http://') || decodedUrl.startsWith('https://')) {
|
if (decodedUrl.startsWith('http://') || decodedUrl.startsWith('https://')) {
|
||||||
|
console.log('Complete URL, returning as is');
|
||||||
return decodedUrl;
|
return decodedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,14 +191,19 @@ class BlogService {
|
|||||||
if (decodedUrl.startsWith('/')) {
|
if (decodedUrl.startsWith('/')) {
|
||||||
// Check if it's a local public path
|
// Check if it's a local public path
|
||||||
if (decodedUrl.startsWith('/images/')) {
|
if (decodedUrl.startsWith('/images/')) {
|
||||||
|
console.log('Local public image');
|
||||||
return decodedUrl;
|
return decodedUrl;
|
||||||
}
|
}
|
||||||
// It's from the backend API
|
// It's from the backend API
|
||||||
return `${this.apiBaseUrl}${decodedUrl}`;
|
const fullUrl = `${this.apiBaseUrl}${decodedUrl}`;
|
||||||
|
console.log('Backend relative path, constructing:', fullUrl);
|
||||||
|
return fullUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, assume it's a backend path without leading /
|
// Otherwise, assume it's a backend path without leading /
|
||||||
return `${this.apiBaseUrl}/${decodedUrl}`;
|
const fullUrl = `${this.apiBaseUrl}/${decodedUrl}`;
|
||||||
|
console.log('Backend path without leading /, constructing:', fullUrl);
|
||||||
|
return fullUrl;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error processing image URL:', imageUrl, error);
|
console.error('Error processing image URL:', imageUrl, error);
|
||||||
return this.getDefaultImage();
|
return this.getDefaultImage();
|
||||||
@ -199,7 +211,8 @@ class BlogService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getDefaultImage(): string {
|
private getDefaultImage(): string {
|
||||||
return '/images/default-blog-image.jpg';
|
// Use a placeholder image service for now
|
||||||
|
return 'https://images.unsplash.com/photo-1505751172876-fa1923c5c528?w=800&h=600&fit=crop';
|
||||||
}
|
}
|
||||||
|
|
||||||
private getFallbackBlogs(): Blog[] {
|
private getFallbackBlogs(): Blog[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user