diff --git a/internal/auth/middleware.go b/internal/auth/middleware.go index 01ea7fbc..4599fea7 100644 --- a/internal/auth/middleware.go +++ b/internal/auth/middleware.go @@ -20,6 +20,10 @@ var publicRoutes = []publicRoute{ {method: http.MethodPost, path: "/login"}, {method: http.MethodGet, path: "/logout"}, + // Crawler noise. + {method: http.MethodGet, path: "/robots.txt"}, + {method: http.MethodGet, path: "/sitemap.xml"}, + // Static assets. {path: "/static", prefix: true}, {path: "/dist", prefix: true}, diff --git a/internal/server/server.go b/internal/server/server.go index 8910d454..30602830 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -36,6 +36,15 @@ func ProvideRouter(cfg config.Config, htmlRender render.HTMLRender) *gin.Engine } c.JSON(http.StatusNotFound, ErrorResponse{Error: "Not found"}) }) + r.GET("/robots.txt", func(c *gin.Context) { + c.String(http.StatusOK, "User-agent: *\nDisallow: /\n") + }) + r.GET("/sitemap.xml", func(c *gin.Context) { + c.String(http.StatusOK, ` + + +`) + }) r.Static("/static", "./static") r.Static("/dist", "./dist") r.HTMLRender = htmlRender