尝试修复

This commit is contained in:
wood chen 2024-09-29 01:08:37 +08:00
parent 34092a41b0
commit 77801f29fa

View File

@ -61,13 +61,24 @@ func Convert(c *fiber.Ctx) error {
log.Debugf("Incoming connection from %s %s %s", c.IP(), reqHostname, reqURIwithQuery) log.Debugf("Incoming connection from %s %s %s", c.IP(), reqHostname, reqURIwithQuery)
// 新增:检查是否为图片文件 isRedirect := c.Query("webp_redirect") == "true"
if !isRedirect {
if !isImageFile(filename) { if !isImageFile(filename) {
log.Infof("Non-image file requested: %s, redirecting to original URL", filename) log.Infof("Non-image file requested: %s, redirecting to original URL", filename)
redirectURL := ""
if proxyMode { if proxyMode {
return c.Redirect(realRemoteAddr, 302) redirectURL = realRemoteAddr
} else { } else {
return c.Redirect(reqURIwithQuery, 302) redirectURL = reqURIwithQuery
}
// 添加标记到重定向 URL
if strings.Contains(redirectURL, "?") {
redirectURL += "&webp_redirect=true"
} else {
redirectURL += "?webp_redirect=true"
}
return c.Redirect(redirectURL, 302)
} }
} }