Skip to content

Commit

Permalink
try second day p3
Browse files Browse the repository at this point in the history
  • Loading branch information
Aweiro committed Nov 4, 2024
1 parent e0112db commit ba6f393
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ app.use(express.json());
app.use(express.urlencoded({ extended: true })); // Додаємо для обробки form-data

// Налаштування статичних файлів
app.use('/uploads', express.static(path.join(__dirname, 'uploads')));
app.use('/css', express.static(path.join(__dirname, '../css')));
app.use('/img', express.static(path.join(__dirname, '../img')));
app.use('/js', express.static(path.join(__dirname, '../js')));
Expand Down Expand Up @@ -118,10 +117,12 @@ app.post('/upload', upload.single('photo'), async (req, res) => {
const { description, decorName, price } = req.body;
if (req.file) {
try {
const publicUrl = `https://firebasestorage.googleapis.com/v0/b/${bucket.name}/o/uploads%2F${encodeURIComponent(req.file.filename)}?alt=media&token=${uniqueToken}`;

const newPhoto = {
name: req.file.filename,
url: `${req.protocol}://${req.get('host')}/uploads/${req.file.filename}`.replace('http:', 'https:'),
description: description || 'Опис відсутній',
url: publicUrl, // Firebase URL для зображення
description: description || 'Опис відсутній',
decorName: decorName || 'Назва декору відсутня',
price: price ? parseFloat(price) : 0
};
Expand Down

0 comments on commit ba6f393

Please sign in to comment.