Fix photo URL construction in ReportDetailModal

- Prepend API base URL to relative photo paths
- Use process.cwd() for upload directory in server
- Ensures photos display correctly in report detail modal
This commit is contained in:
2025-11-16 22:57:40 +00:00
parent 4e5ab7d41b
commit 55acff59bc
2 changed files with 8 additions and 3 deletions

View File

@@ -29,8 +29,9 @@ app.use(cors({
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Serve uploaded files
app.use('/uploads', express.static(path.join(__dirname, '../../uploads')));
// Serve uploaded files - use process.cwd() to get the correct path
const uploadDir = process.env.UPLOAD_DIR || path.join(process.cwd(), 'uploads');
app.use('/uploads', express.static(uploadDir));
// Health check
app.get('/health', (req, res) => {

View File

@@ -125,7 +125,11 @@ export function ReportDetailModal({ report, isOpen, onClose, onVerify, onDispute
{/* Photo Gallery */}
<div className="relative bg-gray-900">
<img
src={report.photoUrls[currentPhotoIndex]}
src={
report.photoUrls[currentPhotoIndex].startsWith('http')
? report.photoUrls[currentPhotoIndex]
: `${(import.meta.env.VITE_API_BASE_URL || 'http://localhost:3005/api').replace('/api', '')}${report.photoUrls[currentPhotoIndex]}`
}
alt={`Report photo ${currentPhotoIndex + 1}`}
className="w-full h-80 object-contain"
/>