ваше сообщение коммита

This commit is contained in:
2026-01-27 09:52:05 +03:00
parent 291d2db367
commit 9cddf7bb35
6 changed files with 42 additions and 55 deletions

View File

@@ -2107,9 +2107,13 @@ router.get('/public/:id', async (req, res, next) => {
// Endpoint для robots.txt
router.get('/public/robots.txt', async (req, res) => {
try {
const domain = req.get('host') || req.headers.host || 'localhost';
const protocol = req.protocol || 'https';
const baseUrl = `${protocol}://${domain}`;
// Используем X-Forwarded-Host если доступен (от nginx), иначе обычный Host
const domain = req.get('x-forwarded-host') || req.get('host') || req.headers.host || 'localhost';
// Убираем порт если он есть (например, localhost:8000 -> localhost)
const cleanDomain = domain.split(':')[0];
// Используем X-Forwarded-Proto если доступен (от nginx), иначе req.protocol
const protocol = req.get('x-forwarded-proto') || req.protocol || 'https';
const baseUrl = `${protocol}://${cleanDomain}`;
const robotsContent = `User-agent: *
Allow: /
@@ -2136,9 +2140,13 @@ Sitemap: ${baseUrl}/sitemap.xml
router.get('/public/sitemap.xml', async (req, res) => {
try {
const tableName = `admin_pages_simple`;
const domain = req.get('host') || req.headers.host || 'localhost';
const protocol = req.protocol || 'https';
const baseUrl = `${protocol}://${domain}`;
// Используем X-Forwarded-Host если доступен (от nginx), иначе обычный Host
const domain = req.get('x-forwarded-host') || req.get('host') || req.headers.host || 'localhost';
// Убираем порт если он есть (например, localhost:8000 -> localhost)
const cleanDomain = domain.split(':')[0];
// Используем X-Forwarded-Proto если доступен (от nginx), иначе req.protocol
const protocol = req.get('x-forwarded-proto') || req.protocol || 'https';
const baseUrl = `${protocol}://${cleanDomain}`;
// Проверяем, есть ли таблица
const existsRes = await db.getQuery()(