Skip to content

Commit

Permalink
Merge pull request #234 from checkr/zz/change-web-prefix
Browse files Browse the repository at this point in the history
Use web prefix for main API
  • Loading branch information
zhouzhuojie authored Mar 20, 2019
2 parents c3ef755 + 88c5da0 commit 8f3c10d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion browser/flagr-ui/config/prod.env.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
NODE_ENV: '"production"',
API_URL: '"/api/v1"',
API_URL: '"api/v1"',

// ',' separated string
// For example
Expand Down
5 changes: 4 additions & 1 deletion pkg/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:""`
}{}
4 changes: 4 additions & 0 deletions pkg/config/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8f3c10d

Please sign in to comment.