diff --git a/server/routes.js b/server/routes.js index ece6031c..86e968f0 100644 --- a/server/routes.js +++ b/server/routes.js @@ -10,6 +10,7 @@ import serve from 'koa-static'; import subdomainRedirect from './middlewares/subdomainRedirect'; import renderpage from './utils/renderpage'; import { slackAuth } from '../shared/utils/routeHelpers'; +import { robotsResponse } from './utils/robots'; import Home from './pages/Home'; import About from './pages/About'; @@ -81,6 +82,9 @@ router.get('/', async ctx => { } }); +// Other +router.get('/robots.txt', ctx => (ctx.body = robotsResponse(ctx))); + // catch all for react app router.get('*', async ctx => { await renderapp(ctx); diff --git a/server/utils/robots.js b/server/utils/robots.js new file mode 100644 index 00000000..f7e08c8e --- /dev/null +++ b/server/utils/robots.js @@ -0,0 +1,9 @@ +// @flow +import { type Context } from 'koa'; + +const DISALLOW_ROBOTS = `User-agent: * +Disallow: /`; + +export const robotsResponse = (ctx: Context): ?string => { + if (ctx.headers.host.indexOf('getoutline.com') < 0) return DISALLOW_ROBOTS; +};