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 1/2] 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 From 04052bfc8e0256915fc616f93ecbc0e858a0c243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Thu, 6 Oct 2022 19:17:03 +0100 Subject: [PATCH 2/2] fix: remove JSON from 404 response --- lib/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/routes.js b/lib/routes.js index 7cc6bb5b..49ddddf2 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -62,7 +62,7 @@ app.use('/robots.txt', (req, res) => { }) app.get('/', (req, res) => { - res.status(404).json({ error: 'No such route' }) + res.sendStatus(404) }) // app /pair and /ca routes