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