From cc6b60f72fbd504628c9b4ea81f31ed69128e4b0 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Wed, 5 Jul 2023 10:39:30 +0000 Subject: [PATCH] [IMP] web: default robots.txt Web lacked a default route for /robots.txt meaning that if you didn't installed website (which comes with a full fledged robots.txt) you would get a 404 page not found. closes odoo/odoo#127402 Signed-off-by: Julien Castiaux (juc) --- addons/web/controllers/home.py | 4 ++++ odoo/addons/test_http/tests/test_misc.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/addons/web/controllers/home.py b/addons/web/controllers/home.py index 455e423aec4..c02e1313e4e 100644 --- a/addons/web/controllers/home.py +++ b/addons/web/controllers/home.py @@ -154,3 +154,7 @@ class Home(http.Controller): headers = [('Content-Type', 'application/json'), ('Cache-Control', 'no-store')] return request.make_response(data, headers) + + @http.route(['/robots.txt'], type='http', auth="none") + def robots(self, **kwargs): + return "User-agent: *\nDisallow: /\n" diff --git a/odoo/addons/test_http/tests/test_misc.py b/odoo/addons/test_http/tests/test_misc.py index 2efddb9f8e0..55f470df737 100644 --- a/odoo/addons/test_http/tests/test_misc.py +++ b/odoo/addons/test_http/tests/test_misc.py @@ -136,6 +136,9 @@ class TestHttpMisc(TestHttpBase): self.assertEqual(res.status_code, 200) self.assertEqual(res.text, file.getvalue()) + def test_misc7_robotstxt(self): + self.nodb_url_open('/robots.txt').raise_for_status() + @tagged('post_install', '-at_install') class TestHttpCors(TestHttpBase): def test_cors0_http_default(self):