diff --git a/.env.development b/.env.development index cc4b377..345948f 100644 --- a/.env.development +++ b/.env.development @@ -1,12 +1,12 @@ -DATABASE=test_PiuCheBuono +DATABASE=test_FreePlanet UDB=paofreeplanet PDB=mypassword@1A SEND_EMAIL=0 SEND_EMAIL_ORDERS=1 PORT=3000 -appTelegram_TEST=["1","17","18"] -appTelegram=["1","17","18"] -appTelegram_DEVELOP=["17"] +appTelegram_TEST=["1","13"] +appTelegram=["1","13"] +appTelegram_DEVELOP=["13"] DOMAIN=mongodb://localhost:27017/ AUTH_MONGODB=1 MONGODB_USER=admin @@ -41,7 +41,4 @@ FTPSERVER_USER=ftpusrsrv_ FTPSERVER_PWD=ftpmypwd@1A_ AUTH_NEW_SITES=123123123 SCRIPTS_DIR=admin_scripts -CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}] -MIAB_HOST=box.lamiaposta.org -MIAB_ADMIN_EMAIL=admin@lamiaposta.org -MIAB_ADMIN_PASSWORD=passpao1pabox@1A \ No newline at end of file +CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}] \ No newline at end of file diff --git a/public/upload/products/LQ_Letsee_100x1120jpeg.jpg b/public/upload/products/LQ_Letsee_100x1120jpeg.jpg new file mode 100644 index 0000000..423b8a3 Binary files /dev/null and b/public/upload/products/LQ_Letsee_100x1120jpeg.jpg differ diff --git a/src/server/models/productInfo.js b/src/server/models/productInfo.js index 0684f3c..abb5dad 100755 --- a/src/server/models/productInfo.js +++ b/src/server/models/productInfo.js @@ -230,7 +230,7 @@ module.exports.getProductByCode = function (idapp, code) { module.exports.replaceProductImgToImageFile = async function () { const ProductInfo = this; - let abilitaserver = false; + let abilitaserver = true; if (abilitaserver) { // const result = await ProductInfo.updateMany({ "img": { $exists: true } }, { $rename: { 'img': 'imagefile' } }); @@ -240,9 +240,9 @@ module.exports.replaceProductImgToImageFile = async function () { // Aggiorna ciascun documento for (let doc of documents) { - if (doc.img && doc.img.startsWith('/upload/products/')) { + if (doc.img && doc.img.startsWith('upload/products/')) { // Rimuovi il prefisso '/upload/products' dal campo `img` - doc.imagefile = doc.img.replace(/^\/upload\/products\//, ''); + doc.imagefile = doc.img.replace(/^\upload\/products\//, ''); doc.img = undefined; // Può anche rimuovere il campo img corrente se desiderato await doc.save(); // Salva il documento aggiornato } diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index 813852c..9a75020 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -1919,8 +1919,15 @@ function uploadFile(req, res, version) { let mydircurrent = process.cwd() + '/src/server/router/upload/' + dir; fromfile = mydircurrent + '/' + oldpath; tofile = mydir + '/' + file.originalFilename; + + // ------------ + // ++TODO: Questo non funziona perché dovrei passargli il nomefile aggiornato a Vue.js + // tofile = tools.cleanFileName(tofile) + // ------------ + let newname = tofile; file.path = newname; + console.log('fromfile', fromfile, 'tofile', tofile) diff --git a/src/server/server.js b/src/server/server.js index d9f2b78..4c69981 100755 --- a/src/server/server.js +++ b/src/server/server.js @@ -169,6 +169,12 @@ myLoad().then(ris => { }, }); + // Serve il tuo service worker da una certa directory + /*app.get('/service-worker.js', (req, res) => { + res.set('Cache-Control', 'no-cache'); // Aggiunge l'intestazione + // res.sendFile(path.join(__dirname, 'service-worker.js')); // Modifica il percorso secondo la tua struttura + });*/ + app.use(cors({ exposedHeaders: ['x-auth', 'x-refrtok'], })); @@ -806,6 +812,54 @@ function startServer(app, port) { console.log('isProduction', isProduction); + /* + + const CORS_ENABLE_FOR_ALL_SITES = true; + + let corsOptions = {}; + + if (CORS_ENABLE_FOR_ALL_SITES) { + corsOptions = { + exposedHeaders: ['x-auth', 'x-refrtok'], // Intestazioni da esporre al client + }; + + } else { + + let myhosts = []; + + for (let i = 0; i < domains.length; i++) { + myhosts.push('https://' + domains[i].hostname); + myhosts.push('https://' + 'api.' + domains[i].hostname); + myhosts.push('https://' + 'test.' + domains[i].hostname); + myhosts.push('https://' + 'testapi.' + domains[i].hostname); + } + + console.log('myhosts', myhosts); + + console.log('CORS'); + + corsOptions = { + origin: (origin, callback) => { + if (myhosts.indexOf(origin) !== -1 || !origin) { + callback(null, true); + } else { + callback(new Error('Not allowed by CORS')); + } + }, + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], + allowedHeaders: ['Content-Type', 'Authorization', 'x-auth', 'x-refrtok'], // Intestazioni consentite + exposedHeaders: ['x-auth', 'x-refrtok'], // Intestazioni da esporre al client + credentials: true, // Consenti l'invio di cookie + preflightContinue: false, + optionsSuccessStatus: 204, + }; + + app.use(cors(corsOptions)); + + }*/ + + + if (isProduction) { for (let i = 0; i < domains.length; i++) { const credentials = getCredentials(domains[i].hostname); diff --git a/src/server/tools/general.js b/src/server/tools/general.js index 7850830..ef8de35 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -5646,7 +5646,7 @@ module.exports = { // mystr = t('movement.from') + userfrom + ' ' + t('movement.to') + userto - return { userfrom: {profile: profilefrom, username: userfrom}, userto: {profile: profileto, username: userto}, tipocontofrom, tipocontoto } + return { userfrom: { profile: profilefrom, username: userfrom }, userto: { profile: profileto, username: userto }, tipocontofrom, tipocontoto } }, ImageDownloader, @@ -5703,8 +5703,20 @@ module.exports = { }, // **ADDFIELD_ANNUNCI }; - + return annunciFields; - }, + }, + + // Funzione per pulire il nome del file + cleanFileName(filePath) { + // Ottieni solo il nome del file dall'intero percorso + // const fileName = filePath.split('/').pop(); + + // Rimuovi apostrofi e sostituisci gli spazi con underscore + const cleanedName = fileName.replace(/'/g, '').replace(/\s+/g, '_'); + + // Restituisci il percorso chiaro; puoi decidere di mantenere il resto del percorso + return cleanedName; + }, }; diff --git a/src/server/version.txt b/src/server/version.txt index 1cc5f65..9c1218c 100644 --- a/src/server/version.txt +++ b/src/server/version.txt @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.1.3 \ No newline at end of file