Fix UI and backend paths with subpath (#1799) (#2133)

This commit is contained in:
qwerty287
2023-08-07 18:43:14 +02:00
committed by GitHub
parent 4b0db4ec86
commit 239b00ca20
30 changed files with 168 additions and 98 deletions

View File

@@ -61,8 +61,8 @@ var flags = []cli.Flag{
Usage: "server fully qualified url for forge's Webhooks (<scheme>://<host>)",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_ROOT_URL"},
Name: "root-url",
EnvVars: []string{"WOODPECKER_ROOT_PATH", "WOODPECKER_ROOT_URL"},
Name: "root-path",
Usage: "server url root (used for statics loading when having a url path prefix)",
},
&cli.StringFlag{

View File

@@ -357,7 +357,11 @@ func setupEvilGlobals(c *cli.Context, v store.Store, f forge.Forge) {
server.Config.Server.StatusContext = c.String("status-context")
server.Config.Server.StatusContextFormat = c.String("status-context-format")
server.Config.Server.SessionExpires = c.Duration("session-expires")
server.Config.Server.RootURL = strings.TrimSuffix(c.String("root-url"), "/")
rootPath := strings.TrimSuffix(c.String("root-path"), "/")
if rootPath != "" && !strings.HasPrefix(rootPath, "/") {
rootPath = "/" + rootPath
}
server.Config.Server.RootPath = rootPath
server.Config.Server.CustomCSSFile = strings.TrimSpace(c.String("custom-css-file"))
server.Config.Server.CustomJsFile = strings.TrimSpace(c.String("custom-js-file"))
server.Config.Pipeline.Networks = c.StringSlice("network")