aggiornamenti vari...
This commit is contained in:
@@ -295,7 +295,7 @@ const getTableContent = async (options) => {
|
||||
// Se c'è un solo record, visualizza una lista di chiavi e valori
|
||||
const record = records[0];
|
||||
output += `
|
||||
< table border = '1' style = "border-collapse: collapse; width: 50%;" >
|
||||
<table border='1' style="border-collapse: collapse; width: 50%;" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="padding: 8px; background-color: #f2f2f2;">Campo</th>
|
||||
@@ -314,7 +314,7 @@ const getTableContent = async (options) => {
|
||||
});
|
||||
output += `
|
||||
</tbody>
|
||||
</table >
|
||||
</table>
|
||||
`;
|
||||
} else {
|
||||
// Se ci sono più record, visualizza una tabella con intestazioni
|
||||
|
||||
@@ -806,6 +806,8 @@ connectToDatabase(connectionUrl, options)
|
||||
`https://test.${domain.hostname}`,
|
||||
`https://testapi.${domain.hostname}`,
|
||||
`https://comunitanuovomondo.app`,
|
||||
`https://kolibrilab.it`,
|
||||
`https://artenergetica.org`,
|
||||
`https://freeplanet.app:3001`,
|
||||
`http://${domain.hostname}`,
|
||||
`http://api.${domain.hostname}`,
|
||||
@@ -822,27 +824,25 @@ connectToDatabase(connectionUrl, options)
|
||||
try {
|
||||
// Validazione dell'input
|
||||
if (!origin || typeof origin !== 'string' || !/^https?:\/\/[^\s/$.?#].[^\s]*$/.test(origin)) {
|
||||
if (origin)
|
||||
console.error('❌ Origine non valida', origin);
|
||||
console.error('❌ Origine non valida:', origin);
|
||||
return callback(new Error('Origine non valida'), false);
|
||||
}
|
||||
|
||||
// Logging per il debug
|
||||
// console.log('Verifica origine:', origin);
|
||||
|
||||
// Controllo delle origini consentite
|
||||
if (!origin || allowedOrigins.includes(origin)) {
|
||||
// console.log('✅ Origine consentita:', origin);
|
||||
if (allowedOrigins.includes(origin)) {
|
||||
console.log('✅ Origine consentita:', origin);
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
// Blocco delle origini non autorizzate
|
||||
console.warn('❌ Origine bloccata:', origin);
|
||||
callback(new Error('CORS non permesso per questa origine ' + origin));
|
||||
return callback(new Error('CORS non permesso per questa origine'), false);
|
||||
} catch (error) {
|
||||
console.error('Errore durante la verifica dell\'origine:', error.message);
|
||||
callback(error);
|
||||
return callback(error, false);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Configurazione CORS dettagliata
|
||||
@@ -874,16 +874,17 @@ connectToDatabase(connectionUrl, options)
|
||||
app.options('*', cors(corsOptions)); // Gestisce tutte le richieste OPTIONS
|
||||
|
||||
// Middleware personalizzato per assicurare gli headers CORS
|
||||
app.use((req, res, next) => {
|
||||
/*app.use((req, res, next) => {
|
||||
const origin = req.headers.origin || '*';
|
||||
if (allowedOrigins.includes(origin) || corsOptions.origin === '*') {
|
||||
// console.log(' ... ORIGIN', origin);
|
||||
res.setHeader('Access-Control-Allow-Origin', origin);
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
||||
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
||||
res.setHeader('Access-Control-Expose-Headers', 'x-auth, x-refrtok');
|
||||
}
|
||||
next();
|
||||
});
|
||||
});*/
|
||||
|
||||
// Log middleware per debug
|
||||
app.use((req, res, next) => {
|
||||
@@ -935,9 +936,16 @@ connectToDatabase(connectionUrl, options)
|
||||
if (process.env.HTTPS_LOCALHOST === "true") {
|
||||
let mycredentials = null;
|
||||
try {
|
||||
|
||||
const keyStream = path.resolve(`./${process.env.PATH_CERT_KEY}`);
|
||||
const certificateStream = path.resolve(`./${process.env.PATH_SERVER_CRT}`);
|
||||
|
||||
const privateKey = fs.readFileSync(keyStream, "utf8");
|
||||
const certificate = fs.readFileSync(certificateStream, "utf8");
|
||||
|
||||
mycredentials = {
|
||||
key: fs.readFileSync(process.env.PATH_CERT_KEY, 'utf8'),
|
||||
cert: fs.readFileSync(process.env.PATH_SERVER_CRT, 'utf8'),
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
ciphers: 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384',
|
||||
honorCipherOrder: true,
|
||||
secureProtocol: 'TLSv1_2_method'
|
||||
|
||||
Reference in New Issue
Block a user