404 in sitemap: sitemap je kazal na /news /video /galerie, ki jih router ne pozna (soft 404); 301 preusmeritve za stare poti (/empfang, /news, /video, /galerie, /about ...); neznana pot vrne pravi HTTP 404 namesto 200

This commit is contained in:
claude
2026-08-20 13:07:56 +02:00
parent ca47bc8698
commit 808e9a5438
2 changed files with 50 additions and 1 deletions
+23
View File
@@ -299,7 +299,30 @@ export function serveStatic(app: Express) {
return;
}
// Neznana pot mora vrniti PRAVI 404, sicer Google dobi soft 404 (HTTP 200
// z naslovnico). Seznam mora ustrezati potem v client/src/App.tsx.
const KNOWN = [
/^\/$/, /^\/search\/?$/, /^\/article\//, /^\/category\//, /^\/aktuelles\/?$/,
/^\/videos\/?$/, /^\/gallery\/?$/, /^\/horoskop(\/|$)/, /^\/rezepte\/?$/,
/^\/empfang-folx-tv\/?$/, /^\/ueber-uns\/?$/, /^\/impressum\/?$/,
/^\/datenschutz\/?$/, /^\/kontakt\/?$/, /^\/admin(\/|$)/,
];
const cleanPath = url.split("?")[0].split("#")[0];
const known = KNOWN.some((re) => re.test(cleanPath));
let template = await fs.promises.readFile(indexPath, "utf-8");
if (!known) {
template = stripExistingMeta(template);
template = template.replace(
/<title>[^<]*<\/title>/,
[
'<title>Seite nicht gefunden | FOLX TV</title>',
'<meta name="robots" content="noindex, follow" />',
].join("\n ")
);
res.status(404).set({ "Content-Type": "text/html" }).end(template);
return;
}
res.status(200).set({ "Content-Type": "text/html" }).end(template);
});
}