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:
@@ -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) => {
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user