尝试修复

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

View File

@ -62,25 +62,25 @@ 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" isRedirect := c.Query("webp_redirect") == "true"
if !isRedirect { 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 := "" var redirectURL string
if proxyMode { if proxyMode {
redirectURL = realRemoteAddr // 在代理模式下使用原始的远程URL
} else { redirectURL = realRemoteAddr
redirectURL = reqURIwithQuery } else {
} // 在非代理模式下构造本地文件的URL
// 添加标记到重定向 URL redirectURL = path.Join(config.Config.ImgPath, reqURI)
if strings.Contains(redirectURL, "?") { }
redirectURL += "&webp_redirect=true"
} else { // 移除查询参数,因为它们可能是用于图像处理的
redirectURL += "?webp_redirect=true" redirectURL = strings.Split(redirectURL, "?")[0]
}
return c.Redirect(redirectURL, 302) log.Infof("Redirecting to: %s", redirectURL)
} return c.Redirect(redirectURL, 302)
} }
}
if !helper.CheckAllowedType(filename) { if !helper.CheckAllowedType(filename) {