mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-10 20:22:31 +02:00
Optionally return rel="canonical" header (#542)
* set rel="canonical" header * check scheme before setting canonical headers, add documentation
This commit is contained in:
@@ -67,6 +67,14 @@ func respondWithImage(ctx context.Context, reqID string, r *http.Request, rw htt
|
||||
rw.Header().Set("Content-Type", po.Format.Mime())
|
||||
rw.Header().Set("Content-Disposition", contentDisposition)
|
||||
|
||||
if conf.SetCanonicalHeader {
|
||||
origin := getImageURL(ctx)
|
||||
if strings.HasPrefix(origin, "https://") || strings.HasPrefix(origin, "http://") {
|
||||
linkHeader := fmt.Sprintf(`<%s>; rel="canonical"`, origin)
|
||||
rw.Header().Set("Link", linkHeader)
|
||||
}
|
||||
}
|
||||
|
||||
var cacheControl, expires string
|
||||
|
||||
if conf.CacheControlPassthrough {
|
||||
|
Reference in New Issue
Block a user