mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-06-17 10:26:25 +08:00
Make public URL generation configurable (#34250)
Follow up #32564 Co-authored-by: Jannis Pohl <838818+jannispl@users.noreply.github.com> Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
This commit is contained in:
@ -41,12 +41,20 @@ const (
|
||||
LandingPageLogin LandingPage = "/user/login"
|
||||
)
|
||||
|
||||
const (
|
||||
PublicURLAuto = "auto"
|
||||
PublicURLLegacy = "legacy"
|
||||
)
|
||||
|
||||
// Server settings
|
||||
var (
|
||||
// AppURL is the Application ROOT_URL. It always has a '/' suffix
|
||||
// It maps to ini:"ROOT_URL"
|
||||
AppURL string
|
||||
|
||||
// PublicURLDetection controls how to use the HTTP request headers to detect public URL
|
||||
PublicURLDetection string
|
||||
|
||||
// AppSubURL represents the sub-url mounting point for gitea, parsed from "ROOT_URL"
|
||||
// It is either "" or starts with '/' and ends without '/', such as '/{sub-path}'.
|
||||
// This value is empty if site does not have sub-url.
|
||||
@ -56,9 +64,6 @@ var (
|
||||
// to make it easier to debug sub-path related problems without a reverse proxy.
|
||||
UseSubURLPath bool
|
||||
|
||||
// UseHostHeader makes Gitea prefer to use the "Host" request header for construction of absolute URLs.
|
||||
UseHostHeader bool
|
||||
|
||||
// AppDataPath is the default path for storing data.
|
||||
// It maps to ini:"APP_DATA_PATH" in [server] and defaults to AppWorkPath + "/data"
|
||||
AppDataPath string
|
||||
@ -283,10 +288,10 @@ func loadServerFrom(rootCfg ConfigProvider) {
|
||||
PerWritePerKbTimeout = sec.Key("PER_WRITE_PER_KB_TIMEOUT").MustDuration(PerWritePerKbTimeout)
|
||||
|
||||
defaultAppURL := string(Protocol) + "://" + Domain + ":" + HTTPPort
|
||||
AppURL = sec.Key("ROOT_URL").String()
|
||||
if AppURL == "" {
|
||||
UseHostHeader = true
|
||||
AppURL = defaultAppURL
|
||||
AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
|
||||
PublicURLDetection = sec.Key("PUBLIC_URL_DETECTION").MustString(PublicURLLegacy)
|
||||
if PublicURLDetection != PublicURLAuto && PublicURLDetection != PublicURLLegacy {
|
||||
log.Fatal("Invalid PUBLIC_URL_DETECTION value: %s", PublicURLDetection)
|
||||
}
|
||||
|
||||
// Check validity of AppURL
|
||||
|
Reference in New Issue
Block a user