Fix storage path issues and React error #130
Backend fixes: - Add STORAGE_PATH environment variable support - Fix absolute path references in all backend services - Update Docker configuration with correct storage path Frontend fixes: - Remove individual ErrorBoundary wrappers to fix React error #130 - Remove unused ErrorBoundary import - Simplify route structure to prevent component mounting issues This resolves: - 500 errors when creating events due to storage permission issues - React error #130 that occurred during event creation - Consistent storage path handling across all services 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -60,7 +60,8 @@ router.post('/', adminAuth, [
|
||||
expires_at.setDate(expires_at.getDate() + expiration_days);
|
||||
|
||||
// Create folder structure
|
||||
const eventPath = path.join(__dirname, '../../../storage/events/active', slug);
|
||||
const storagePath = process.env.STORAGE_PATH || path.join(__dirname, '../../../storage');
|
||||
const eventPath = path.join(storagePath, 'events/active', slug);
|
||||
await fs.mkdir(path.join(eventPath, 'collages'), { recursive: true });
|
||||
await fs.mkdir(path.join(eventPath, 'individual'), { recursive: true });
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ router.post('/', adminAuth, [
|
||||
expires_at.setDate(expires_at.getDate() + expiration_days);
|
||||
|
||||
// Create folder structure
|
||||
const eventPath = path.join(__dirname, '../../../storage/events/active', slug);
|
||||
const storagePath = process.env.STORAGE_PATH || path.join(__dirname, '../../../storage');
|
||||
const eventPath = path.join(storagePath, 'events/active', slug);
|
||||
await fs.mkdir(path.join(eventPath, 'collages'), { recursive: true });
|
||||
await fs.mkdir(path.join(eventPath, 'individual'), { recursive: true });
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ const archiver = require('archiver');
|
||||
const path = require('path');
|
||||
const router = express.Router();
|
||||
|
||||
// Get storage path from environment or default
|
||||
const getStoragePath = () => process.env.STORAGE_PATH || path.join(__dirname, '../../../storage');
|
||||
|
||||
// Middleware to verify gallery access
|
||||
async function verifyGalleryAccess(req, res, next) {
|
||||
try {
|
||||
@@ -115,7 +118,7 @@ router.get('/:slug/download/:photoId', verifyGalleryAccess, async (req, res) =>
|
||||
photo_id: photoId
|
||||
});
|
||||
|
||||
const filePath = path.join(__dirname, '../../../storage/events/active', req.event.slug, photo.path);
|
||||
const filePath = path.join(getStoragePath(), 'events/active', req.event.slug, photo.path);
|
||||
res.download(filePath, photo.filename);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to download photo' });
|
||||
@@ -143,7 +146,7 @@ router.get('/:slug/download-all', verifyGalleryAccess, async (req, res) => {
|
||||
|
||||
// Add photos to archive
|
||||
for (const photo of photos) {
|
||||
const filePath = path.join(__dirname, '../../../storage/events/active', req.event.slug, photo.path);
|
||||
const filePath = path.join(getStoragePath(), 'events/active', req.event.slug, photo.path);
|
||||
archive.file(filePath, { name: photo.path });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user