mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
尝试修复
This commit is contained in:
parent
34092a41b0
commit
77801f29fa
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user