forked from UKSOURCE/cms.hailearning.edu.vn
change || to ??
This commit is contained in:
@@ -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}`;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user