From 37e235452b5c5ba1f4463a3fc493a56e6fe46c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Fri, 16 Sep 2022 05:26:30 +0100 Subject: [PATCH] feat: add robots.txt to lamassu-server and lamassu-admin fix: fail fast on lamassu-server default route access --- lib/routes.js | 9 +++++++++ new-lamassu-admin/public/robots.txt | 2 ++ 2 files changed, 11 insertions(+) create mode 100644 new-lamassu-admin/public/robots.txt diff --git a/lib/routes.js b/lib/routes.js index 6248fc8e..7cc6bb5b 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -56,6 +56,15 @@ app.use(nocache()) app.use(express.json({ limit: '2mb' })) app.use(morgan(':method :url :status :response-time ms -- :req[content-length]/:res[content-length] b', { stream: logger.stream })) +app.use('/robots.txt', (req, res) => { + res.type('text/plain') + res.send("User-agent: *\nDisallow: /") +}) + +app.get('/', (req, res) => { + res.status(404).json({ error: 'No such route' }) +}) + // app /pair and /ca routes app.use('/', pairingRoutes) diff --git a/new-lamassu-admin/public/robots.txt b/new-lamassu-admin/public/robots.txt new file mode 100644 index 00000000..77470cb3 --- /dev/null +++ b/new-lamassu-admin/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / \ No newline at end of file