fix: priority ^~ /uploads/ routing in Nginx and share strapi_uploads volume with backend
This commit is contained in:
@@ -344,7 +344,7 @@ export default function BlogDetailPage({ blog, allBlogs = [], isMobile, onNaviga
|
||||
</div>
|
||||
|
||||
{/* HERO FEATURED IMAGE */}
|
||||
{blog.image && (
|
||||
{(blog.image || blog.coverImage || blog.ogImage) && (
|
||||
<div style={{
|
||||
width: '100%',
|
||||
height: isMobile ? '250px' : '520px',
|
||||
@@ -356,9 +356,24 @@ export default function BlogDetailPage({ blog, allBlogs = [], isMobile, onNaviga
|
||||
boxShadow: '0 25px 60px rgba(0, 0, 0, 0.75)'
|
||||
}}>
|
||||
<img
|
||||
src={assetUrl(blog.image)}
|
||||
src={assetUrl(blog.image || blog.coverImage || blog.ogImage)}
|
||||
alt={blog.title}
|
||||
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
|
||||
onError={(e) => {
|
||||
const titleLower = (blog.title || '').toLowerCase();
|
||||
const catLower = (blog.category || '').toLowerCase();
|
||||
let fallback = '/assets/arvindh_agentic_ai.jpg';
|
||||
if (titleLower.includes('llm')) fallback = '/assets/arvindh_llm_financial.jpg';
|
||||
else if (titleLower.includes('supply chain')) fallback = '/assets/arvindh_supply_chain.jpg';
|
||||
else if (titleLower.includes('prodmax')) fallback = '/assets/prodmax_dashboard.png';
|
||||
else if (titleLower.includes('vr') || titleLower.includes('incidents')) fallback = '/assets/whyus_vr_man.jpg';
|
||||
else if (titleLower.includes('scada') || titleLower.includes('plc') || titleLower.includes('speed vs')) fallback = '/assets/arvindh_agentic_ai.jpg';
|
||||
else if (catLower.includes('ai')) fallback = '/assets/arvindh_agentic_ai.jpg';
|
||||
const resolvedFallback = assetUrl(fallback);
|
||||
if (e.currentTarget.src !== resolvedFallback) {
|
||||
e.currentTarget.src = resolvedFallback;
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@@ -646,14 +661,12 @@ export default function BlogDetailPage({ blog, allBlogs = [], isMobile, onNaviga
|
||||
</ol>
|
||||
);
|
||||
}
|
||||
const imgMatch = block.match(/!\[(.*?)\]\((.*?)\)/);
|
||||
if (imgMatch) {
|
||||
const caption = imgMatch[1] ? imgMatch[1].trim() : '';
|
||||
let rawImgUrl = imgMatch[2];
|
||||
let resolvedSrc = assetUrl(rawImgUrl);
|
||||
if (rawImgUrl.startsWith('http://localhost:1337/uploads/')) {
|
||||
resolvedSrc = assetUrl(rawImgUrl.replace('http://localhost:1337', ''));
|
||||
}
|
||||
const mdImgMatch = block.match(/!\[(.*?)\]\((.*?)\)/);
|
||||
const htmlImgMatch = block.match(/<img[^>]+src=["']([^"']+)["'][^>]*>/i);
|
||||
if (mdImgMatch || htmlImgMatch) {
|
||||
const caption = mdImgMatch ? (mdImgMatch[1] ? mdImgMatch[1].trim() : '') : '';
|
||||
const rawImgUrl = mdImgMatch ? mdImgMatch[2] : htmlImgMatch[1];
|
||||
const resolvedSrc = assetUrl(rawImgUrl);
|
||||
const isFilename = caption && /\.(jpg|jpeg|png|gif|webp|svg|bmp)$/i.test(caption);
|
||||
const displayCaption = caption && !isFilename ? caption : null;
|
||||
|
||||
@@ -671,9 +684,12 @@ export default function BlogDetailPage({ blog, allBlogs = [], isMobile, onNaviga
|
||||
boxShadow: '0 15px 35px rgba(0,0,0,0.5)'
|
||||
}}
|
||||
onError={(e) => {
|
||||
if (rawImgUrl.includes('/uploads/')) {
|
||||
if (rawImgUrl && rawImgUrl.includes('/uploads/')) {
|
||||
const uploadPath = rawImgUrl.substring(rawImgUrl.indexOf('/uploads/'));
|
||||
e.currentTarget.src = `http://localhost:1337${uploadPath}`;
|
||||
const fallback = assetUrl(uploadPath);
|
||||
if (e.currentTarget.src !== fallback) {
|
||||
e.currentTarget.src = fallback;
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user