From 5fa29fd33de72776f49043f0bbc5a88b236e4d0a Mon Sep 17 00:00:00 2001 From: kalugin66 Date: Tue, 4 Aug 2026 15:57:56 +0500 Subject: [PATCH] www --- public/index.html | 5 +---- server.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/public/index.html b/public/index.html index 1abf8ae..40fbaa0 100644 --- a/public/index.html +++ b/public/index.html @@ -743,10 +743,7 @@ img { max-width: 100%; display: block; }
-
-

Демонтаж трубопроводов и утилизация отходов по всей России

-
-
+
diff --git a/server.js b/server.js index 3871933..81d6748 100644 --- a/server.js +++ b/server.js @@ -6,6 +6,29 @@ const sharp = require('sharp'); require('dotenv').config(); const app = express(); + +app.use((req, res, next) => { + const proto = req.headers['x-forwarded-proto']; + if (proto && proto !== 'https') { + return res.redirect(301, 'https://' + req.headers.host + req.url); + } + next(); +}); + +app.use((req, res, next) => { + const host = req.hostname; + if (host.startsWith('www.')) { + const target = host.replace(/^www\./, ''); + return res.redirect(301, 'https://' + target + req.originalUrl); + } + next(); +}); + +app.use((req, res, next) => { + res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload'); + next(); +}); + const PORT = process.env.PORT || 3000; const API_KEY = process.env.HOTEL777KEY; if (!API_KEY) {