修复在 proxy 时重定向的问题

This commit is contained in:
ExplodingDragon
2025-05-15 20:25:12 +08:00
parent 70706fe969
commit b8cf863f18
5 changed files with 52 additions and 7 deletions

View File

@@ -77,9 +77,6 @@ func (p *PageDomain) ReturnMeta(owner string, repo string, branch string, path [
rel.Owner = owner
rel.Repo = repo
rel.Path = strings.Join(path, "/")
if strings.HasSuffix(rel.Path, "/") || rel.Path == "" {
rel.Path = rel.Path + "index.html"
}
if err = p.alias.Bind(meta.Alias, rel.Owner, rel.Repo, branch); err != nil {
zap.L().Warn("别名绑定失败", zap.Error(err))
return nil, err

View File

@@ -144,6 +144,11 @@ func (s *Server) Serve(writer http.ResponseWriter, request *http.Request) error
}
}
}
// 在非反向代理时处理目录访问
if strings.HasSuffix(meta.Path, "/") || meta.Path == "" {
meta.Path = meta.Path + "index.html"
}
// 如果不是反向代理路由则跳过任何配置
if request.Method != "GET" {
return os.ErrNotExist