gogs/gogs

Use user request 'Host' replace `conf.Server.ExternalURL` in `internal/route/lfs /batch.go`

whtiehack opened this issue · 0 comments

Describe the feature

Because gogs may be reverse proxied, accessed by IP address on an internal network, or accessed by multiple different domain names on an external network.

Therefore, these access methods will directly return the conf.Server.ExternalURL address when using LFS.

baseHref := fmt.Sprintf("%s%s/%s.git/info/lfs/objects/basic", conf.Server.ExternalURL, owner.Name, repo.Name)


This will cause two problems:

  1. When pulling lfs objects, it will prompt for login again.

  2. When the ExternalURL is configured as an internal IP, accessing the domain name from external network will return the configured internal IP when pulling LFS objects.

Describe the solution you'd like

baseHref := fmt.Sprintf("%s%s/%s.git/info/lfs/objects/basic", conf.Server.ExternalURL, owner.Name, repo.Name)

Replace conf.Server.ExternalURL with Host in the user's request.

Describe alternatives you've considered

None

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct