Add debug logging for file preview errors

- Add console logging when setting preview proxy URL
- Enhance error handler to capture and log error event details
- Log current preview URL on load failure for debugging
This commit is contained in:
Matt 2025-06-04 17:27:04 +02:00
parent 9e9c667d1f
commit e377662935
1 changed files with 6 additions and 2 deletions

View File

@ -158,7 +158,9 @@ const loadPreview = async () => {
// For images and PDFs, use the proxy endpoint to avoid CORS issues // For images and PDFs, use the proxy endpoint to avoid CORS issues
if (isImage.value || isPdf.value) { if (isImage.value || isPdf.value) {
// Use the proxy endpoint that serves the file directly // Use the proxy endpoint that serves the file directly
previewUrl.value = `/api/files/proxy-preview?fileName=${encodeURIComponent(props.file.name)}`; const proxyUrl = `/api/files/proxy-preview?fileName=${encodeURIComponent(props.file.name)}`;
console.log('Setting preview URL to:', proxyUrl);
previewUrl.value = proxyUrl;
// The loading state will be handled by the image/iframe onload event // The loading state will be handled by the image/iframe onload event
} else { } else {
throw new Error('File type does not support preview'); throw new Error('File type does not support preview');
@ -170,7 +172,9 @@ const loadPreview = async () => {
}; };
// Handle preview load error // Handle preview load error
const handlePreviewError = () => { const handlePreviewError = (event: any) => {
console.error('Preview load error:', event);
console.error('Current preview URL:', previewUrl.value);
error.value = 'Failed to load preview'; error.value = 'Failed to load preview';
loading.value = false; loading.value = false;
}; };