From 50332f2548769d8efbdcd3582b77e607753b70ef Mon Sep 17 00:00:00 2001 From: nthanhtoan61 Date: Mon, 13 Apr 2026 14:39:00 +0700 Subject: [PATCH] change || to ?? --- controllers/degreeController.js | 2 +- utils/imageHelper.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/degreeController.js b/controllers/degreeController.js index b3eb5ea..f95b63d 100644 --- a/controllers/degreeController.js +++ b/controllers/degreeController.js @@ -189,7 +189,7 @@ exports.destroy = async (req, res) => { function buildSecureUrl(req, filename) { if (!filename) return undefined; - const baseUrl = `${req.protocol}://${req.get('host')}`; + const baseUrl = process.env.BACKEND_URL ?? `${req.protocol}://${req.get('host')}`; const name = path.basename(filename); return `${baseUrl}/secure-files/${name}?api_key=${req.query.api_key}`; } diff --git a/utils/imageHelper.js b/utils/imageHelper.js index a894130..bdbebff 100644 --- a/utils/imageHelper.js +++ b/utils/imageHelper.js @@ -5,7 +5,7 @@ */ function addBaseUrlToImages(data, baseUrl) { // Use passed baseUrl, then env var, then default to localhost:3001 - const BACKEND_URL = (baseUrl || process.env.BACKEND_URL || "http://localhost:3001").replace(/\/$/, ""); + const BACKEND_URL = (baseUrl ?? process.env.BACKEND_URL ?? "http://localhost:3001").replace(/\/$/, ""); // Tạo bản sao sâu để tránh thay đổi dữ liệu gốc const processedData = JSON.parse(JSON.stringify(data));