Skip to content

Commit 7eb1d9d

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]>
1 parent 7758df4 commit 7eb1d9d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

services/context/repo.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ func RedirectToRepo(ctx *Base, redirectRepoID int64) {
356356
if ctx.Req.URL.RawQuery != "" {
357357
redirectPath += "?" + ctx.Req.URL.RawQuery
358358
}
359-
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusTemporaryRedirect)
359+
// Git client needs a 301 redirect by default to follow the new location
360+
// It's not documentated in git documentation, but it's the behavior of git client
361+
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusMovedPermanently)
360362
}
361363

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

0 commit comments

Comments
 (0)