summaryrefslogtreecommitdiff
path: root/internal/middleware/extraheaders.go
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2024-08-02 18:22:39 +0200
committerLibravatar GitHub <noreply@github.com>2024-08-02 18:22:39 +0200
commit9b50151f17b5921b68b3c413a26edf8ec6cdc6f8 (patch)
tree30b422982c0798870232835314fbaa827ad57a9a /internal/middleware/extraheaders.go
parent[bugfix] close files before error return (#3163) (diff)
downloadgotosocial-9b50151f17b5921b68b3c413a26edf8ec6cdc6f8.tar.xz
[feature] Beef up our AI opt-outs (#3165)
* [chore] Synchronise our robots.txt with upstream * [feature] Add headers to escape AI crawlers This adds 2 headers that a number of AI crawlers respect to signal that content should not be included in their datasets.
Diffstat (limited to 'internal/middleware/extraheaders.go')
-rw-r--r--internal/middleware/extraheaders.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/middleware/extraheaders.go b/internal/middleware/extraheaders.go
index c75b65551..fb91bcc93 100644
--- a/internal/middleware/extraheaders.go
+++ b/internal/middleware/extraheaders.go
@@ -44,5 +44,12 @@ func ExtraHeaders() gin.HandlerFunc {
//
// See: https://github.com/patcg-individual-drafts/topics
c.Header("Permissions-Policy", "browsing-topics=()")
+
+ // Some AI scrapers respect the following tags to opt-out
+ // of their crawling and datasets.
+ c.Header("X-Robots-Tag", "noimageai")
+ // c.Header calls .Set(), but we want to emit the header
+ // twice, not override it.
+ c.Writer.Header().Add("X-Robots-Tag", "noai")
}
}