From 5524c73eed37a0f59fa6981ffb12f709645a4da9 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Mon, 18 May 2026 13:18:31 +0800 Subject: [PATCH] chore(webui): keep search engines out of the admin surface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even the login page leaks "there's a SnowLuma admin panel at this IP / hostname" to anyone scanning, and right now that page is publicly indexable. Three overlapping signals so we don't depend on any one being honoured: 1. Hono middleware on every response sends X-Robots-Tag: noindex, nofollow, noarchive, nosnippet, noimageindex Hardest for compliant bots to ignore — it's a header, not content. noimageindex also covers logo.png / avatar/* from showing up in image search. 2. A GET /robots.txt route returns "User-agent: * / Disallow: /" for crawlers that read it before fetching pages. Sits before the auth middleware so no token is required (otherwise the crawler would get 401 here, which it'd then refuse to obey). 3. (plus googlebot / bingbot) in index.html as a fallback for the case where a reverse proxy strips the X-Robots-Tag header. --- packages/core/src/webui/server.ts | 20 ++++++++++++++++++++ packages/webui/index.html | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/packages/core/src/webui/server.ts b/packages/core/src/webui/server.ts index 70acff33..1848eb0a 100644 --- a/packages/core/src/webui/server.ts +++ b/packages/core/src/webui/server.ts @@ -116,6 +116,26 @@ export async function initWebUI( const app = new Hono(); + // ─── Anti-indexing ─────────────────────────────────────────────────────── + // The WebUI is an admin surface that has no business showing up in + // search results — even the login page leaks the existence of a + // SnowLuma instance to anyone scanning the IP. Three overlapping + // signals: a hard X-Robots-Tag on every response, a robots.txt for + // crawlers that read it before pages, and a in the + // SPA shell for the case where a proxy strips headers. + app.use('*', async (c, next) => { + await next(); + c.res.headers.set( + 'X-Robots-Tag', + 'noindex, nofollow, noarchive, nosnippet, noimageindex', + ); + }); + + app.get('/robots.txt', (c) => { + c.res.headers.set('Content-Type', 'text/plain; charset=utf-8'); + return c.body('User-agent: *\nDisallow: /\n'); + }); + // ─── Auth middleware ───────────────────────────────────────────────────── app.use('/api/*', async (c, next) => { const reqPath = c.req.path; diff --git a/packages/webui/index.html b/packages/webui/index.html index b6b77b81..b9498433 100644 --- a/packages/webui/index.html +++ b/packages/webui/index.html @@ -5,6 +5,10 @@ + + + +