Skip to content

Commit 50f8563

Browse files
lunnywxiaoguang
authored andcommitted
Git client will follow 301 but 307 (go-gitea#34005)
Fix go-gitea#28460 --------- Co-authored-by: wxiaoguang <[email protected]> (cherry picked from commit 356b707)
1 parent f68d49c commit 50f8563

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

services/context/repo.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ func RedirectToRepo(ctx *Base, redirectRepoID int64) {
361361
if ctx.Req.URL.RawQuery != "" {
362362
redirectPath += "?" + ctx.Req.URL.RawQuery
363363
}
364-
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusTemporaryRedirect)
364+
// Git client needs a 301 redirect by default to follow the new location
365+
// It's not documentated in git documentation, but it's the behavior of git client
366+
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusMovedPermanently)
365367
}
366368

367369
func repoAssignment(ctx *Context, repo *repo_model.Repository) {

0 commit comments

Comments
 (0)