mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 09:40:10 +00:00
fix(dashboard): noindex all paths other than root and status
This commit is contained in:
parent
008caa8473
commit
eb7df8bddb
2 changed files with 10 additions and 2 deletions
2
.github/workflows/dashboard.yml
vendored
2
.github/workflows/dashboard.yml
vendored
|
|
@ -2,9 +2,9 @@ name: Build dashboard Docker image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
|
||||||
paths:
|
paths:
|
||||||
- 'dashboard/**'
|
- 'dashboard/**'
|
||||||
|
- '.github/workflows/dashboard.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,23 @@ func main() {
|
||||||
|
|
||||||
r.Use(func(next http.Handler) http.Handler {
|
r.Use(func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
// only index root and status pages
|
||||||
|
if r.URL.Path != "/" && r.URL.Path != "/status" {
|
||||||
|
rw.Header().Set("X-Robots-Tag", "noindex")
|
||||||
|
}
|
||||||
|
|
||||||
rw.Header().Set("X-PluralKit-Version", version)
|
rw.Header().Set("X-PluralKit-Version", version)
|
||||||
next.ServeHTTP(rw, r)
|
next.ServeHTTP(rw, r)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
r.Get("/robots.txt", func(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
rw.Write([]byte("User-Agent: *\nAllow: /$\nAllow: /status\nDisallow: /\n"))
|
||||||
|
})
|
||||||
|
|
||||||
r.NotFound(notFoundHandler)
|
r.NotFound(notFoundHandler)
|
||||||
|
|
||||||
r.Get("/profile/{type}/{id}", func(rw http.ResponseWriter, r *http.Request) {
|
r.Get("/profile/{type}/{id}", func(rw http.ResponseWriter, r *http.Request) {
|
||||||
rw.Header().Set("X-Robots-Tag", "noindex")
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if a := recover(); a != nil {
|
if a := recover(); a != nil {
|
||||||
notFoundHandler(rw, r)
|
notFoundHandler(rw, r)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue