CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/hub/servers/robots.ts
Views: 687
1
import { get_server_settings } from "@cocalc/database/postgres/server-settings";
2
import { database } from "./database";
3
4
export default function getHandler() {
5
return async (_req, res) => {
6
const settings = await get_server_settings(database); // don't worry -- this is cached.
7
res.header("Content-Type", "text/plain");
8
res.header("Cache-Control", "public, max-age=3600, must-revalidate");
9
if (!settings.landing_pages) {
10
// Default: -- disable everything except /share.
11
res.write(`User-agent: *
12
Allow: /share
13
Disallow: /
14
`);
15
} else {
16
// If landing pages are enabled, which should only be cocalc.com (and maybe some test sites temporarily),
17
// then we only disallow some obvious bad routes. This allows the share server, landing pages, etc.
18
// If we need to switch to a whitelist, see app/next.ts for what to allow...
19
res.write(`User-agent: *
20
Disallow: /static/
21
Disallow: /projects/
22
Disallow: /*/raw/
23
Disallow: /*/port/
24
Disallow: /*/server/
25
Disallow: /haproxy
26
`);
27
}
28
res.end();
29
};
30
}
31
32