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
77801f29fa
commit
214d189e24
@ -62,22 +62,22 @@ 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 {
|
||||||
|
// 在代理模式下,使用原始的远程URL
|
||||||
redirectURL = realRemoteAddr
|
redirectURL = realRemoteAddr
|
||||||
} else {
|
} else {
|
||||||
redirectURL = reqURIwithQuery
|
// 在非代理模式下,构造本地文件的URL
|
||||||
}
|
redirectURL = path.Join(config.Config.ImgPath, reqURI)
|
||||||
// 添加标记到重定向 URL
|
|
||||||
if strings.Contains(redirectURL, "?") {
|
|
||||||
redirectURL += "&webp_redirect=true"
|
|
||||||
} else {
|
|
||||||
redirectURL += "?webp_redirect=true"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移除查询参数,因为它们可能是用于图像处理的
|
||||||
|
redirectURL = strings.Split(redirectURL, "?")[0]
|
||||||
|
|
||||||
|
log.Infof("Redirecting to: %s", redirectURL)
|
||||||
return c.Redirect(redirectURL, 302)
|
return c.Redirect(redirectURL, 302)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user