chore(webui): keep search engines out of the admin surface
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. <meta name="robots"> (plus googlebot / bingbot) in index.html
as a fallback for the case where a reverse proxy strips the
X-Robots-Tag header.
This commit is contained in:
2 files changed
+24
No files matched your search
@@ -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 <meta robots> 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;
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
<link rel="icon" type="image/png" href="/logo.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||
<meta name="theme-color" content="#0ea5e9" />
|
||||
<!-- WebUI is an admin surface; tell every compliant crawler to skip it. -->
|
||||
<meta name="robots" content="noindex, nofollow, noarchive, nosnippet" />
|
||||
<meta name="googlebot" content="noindex, nofollow, noarchive, nosnippet" />
|
||||
<meta name="bingbot" content="noindex, nofollow, noarchive, nosnippet" />
|
||||
<title>SnowLuma 控制台</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
|
||||
Reference in new issue
Block a user