diff --git a/browser/flagr-ui/config/prod.env.js b/browser/flagr-ui/config/prod.env.js index b751cf81..4fe12748 100644 --- a/browser/flagr-ui/config/prod.env.js +++ b/browser/flagr-ui/config/prod.env.js @@ -1,6 +1,6 @@ module.exports = { NODE_ENV: '"production"', - API_URL: '"/api/v1"', + API_URL: '"api/v1"', // ',' separated string // For example diff --git a/pkg/config/env.go b/pkg/config/env.go index 1cad5751..13dc5630 100644 --- a/pkg/config/env.go +++ b/pkg/config/env.go @@ -167,6 +167,9 @@ var Config = struct { // "HS256" and "RS256" supported JWTAuthSigningMethod string `env:"FLAGR_JWT_AUTH_SIGNING_METHOD" envDefault:"HS256"` - // WebPrefix - base path for web + // WebPrefix - base path for web and API + // e.g. FLAGR_WEB_PREFIX=/foo + // UI path => localhost:18000/foo" + // API path => localhost:18000/foo/api/v1" WebPrefix string `env:"FLAGR_WEB_PREFIX" envDefault:""` }{} diff --git a/pkg/config/middleware.go b/pkg/config/middleware.go index dce7bbd8..d17f267f 100644 --- a/pkg/config/middleware.go +++ b/pkg/config/middleware.go @@ -86,6 +86,10 @@ func SetupGlobalMiddleware(handler http.Handler) http.Handler { n.Use(setupRecoveryMiddleware()) + if Config.WebPrefix != "" { + handler = http.StripPrefix(Config.WebPrefix, handler) + } + if Config.PProfEnabled { n.UseHandler(pprof.New()(handler)) } else {