Domain support

This commit is contained in:
salvacybersec
2025-11-10 20:01:41 +03:00
parent dea1b874b5
commit f86cda2978
24 changed files with 3703 additions and 34 deletions

View File

@@ -97,6 +97,89 @@ exports.updateTelegramSettings = async (req, res, next) => {
}
};
// Update System settings (domain, etc.)
exports.updateSystemSettings = async (req, res, next) => {
try {
const { base_url, frontend_url, cors_enabled } = req.body;
if (base_url !== undefined) {
if (base_url) {
// Remove trailing slash if exists
const cleanUrl = base_url.trim().replace(/\/$/, '');
// Basic URL validation
try {
new URL(cleanUrl);
} catch (e) {
return res.status(400).json({
success: false,
error: 'Geçersiz Base URL formatı. Örnek: https://yourdomain.com',
});
}
await Settings.upsert({
key: 'base_url',
value: cleanUrl,
is_encrypted: false,
description: 'Base URL for tracking links (backend)',
});
// Update process.env for immediate use
process.env.BASE_URL = cleanUrl;
} else {
await Settings.destroy({ where: { key: 'base_url' } });
}
}
if (frontend_url !== undefined) {
if (frontend_url) {
// Remove trailing slash if exists
const cleanUrl = frontend_url.trim().replace(/\/$/, '');
// Basic URL validation
try {
new URL(cleanUrl);
} catch (e) {
return res.status(400).json({
success: false,
error: 'Geçersiz Frontend URL formatı. Örnek: https://panel.yourdomain.com',
});
}
await Settings.upsert({
key: 'frontend_url',
value: cleanUrl,
is_encrypted: false,
description: 'Frontend URL (for CORS)',
});
} else {
await Settings.destroy({ where: { key: 'frontend_url' } });
}
}
if (cors_enabled !== undefined) {
await Settings.upsert({
key: 'cors_enabled',
value: cors_enabled ? 'true' : 'false',
is_encrypted: false,
description: 'Enable CORS for separate domains',
});
}
// Update CORS configuration if available
if (req.app && req.app.updateCorsSettings) {
await req.app.updateCorsSettings();
}
res.json({
success: true,
message: 'Sistem ayarları güncellendi. CORS ayarları uygulandı.',
});
} catch (error) {
next(error);
}
};
// Test Gmail connection
exports.testGmail = async (req, res, next) => {
try {