mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	ROOT_URL setting use the default as shown in conf/app.ini (#1823)
The well commented conf/app.ini file that comes with the code shows the
ROOT_URL (i.e. setting.AppURL) as:
    ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
However the installed custom/conf/app.ini file does not include this setting as
shown, and the default in the setting module was hard coded to
http://localhost:3000/ instead of what is shown above.
With this change the ROOT_URL will default to what is shown above if it is not
set in the custom/conf/app.ini.
Of course it is still possible to override the default by adding the ROOT_URL
setting to your custom/conf/app.ini file as usual.
Signed-off-by: Mike Fellows <mike.fellows@shaw.ca>
			
			
This commit is contained in:
		@@ -624,18 +624,6 @@ please consider changing to GITEA_CUSTOM`)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	sec := Cfg.Section("server")
 | 
						sec := Cfg.Section("server")
 | 
				
			||||||
	AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
 | 
						AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
 | 
				
			||||||
	AppURL = sec.Key("ROOT_URL").MustString("http://localhost:3000/")
 | 
					 | 
				
			||||||
	AppURL = strings.TrimRight(AppURL, "/") + "/"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Check if has app suburl.
 | 
					 | 
				
			||||||
	url, err := url.Parse(AppURL)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	// Suburl should start with '/' and end without '/', such as '/{subpath}'.
 | 
					 | 
				
			||||||
	// This value is empty if site does not have sub-url.
 | 
					 | 
				
			||||||
	AppSubURL = strings.TrimSuffix(url.Path, "/")
 | 
					 | 
				
			||||||
	AppSubURLDepth = strings.Count(AppSubURL, "/")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Protocol = HTTP
 | 
						Protocol = HTTP
 | 
				
			||||||
	if sec.Key("PROTOCOL").String() == "https" {
 | 
						if sec.Key("PROTOCOL").String() == "https" {
 | 
				
			||||||
@@ -656,6 +644,24 @@ please consider changing to GITEA_CUSTOM`)
 | 
				
			|||||||
	Domain = sec.Key("DOMAIN").MustString("localhost")
 | 
						Domain = sec.Key("DOMAIN").MustString("localhost")
 | 
				
			||||||
	HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
 | 
						HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
 | 
				
			||||||
	HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
 | 
						HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						defaultAppURL := string(Protocol) + "://" + Domain
 | 
				
			||||||
 | 
						if (Protocol == HTTP && HTTPPort != "80") || (Protocol == HTTPS && HTTPPort != "443") {
 | 
				
			||||||
 | 
							defaultAppURL += ":" + HTTPPort
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
 | 
				
			||||||
 | 
						AppURL = strings.TrimRight(AppURL, "/") + "/"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Check if has app suburl.
 | 
				
			||||||
 | 
						url, err := url.Parse(AppURL)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// Suburl should start with '/' and end without '/', such as '/{subpath}'.
 | 
				
			||||||
 | 
						// This value is empty if site does not have sub-url.
 | 
				
			||||||
 | 
						AppSubURL = strings.TrimSuffix(url.Path, "/")
 | 
				
			||||||
 | 
						AppSubURLDepth = strings.Count(AppSubURL, "/")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(string(Protocol) + "://localhost:" + HTTPPort + "/")
 | 
						LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(string(Protocol) + "://localhost:" + HTTPPort + "/")
 | 
				
			||||||
	OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
 | 
						OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
 | 
				
			||||||
	DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
 | 
						DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user