Skip to content

Commit e72bf2e

Browse files
committed
Added HTTP headers required for gradio
1 parent 5d9b9b5 commit e72bf2e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

internal/app/container_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ func (m *ContainerManager) ProdReload(dryRun bool) error {
687687
err = m.command.RunContainer(m.systemConfig, m.app.AppEntry, containerName,
688688
imageName, m.port, envMap, m.getMountArgs(), m.app.Metadata.ContainerOptions)
689689
if err != nil {
690-
return fmt.Errorf("error building image: %w", err)
690+
return fmt.Errorf("error starting container: %w", err)
691691
}
692692

693693
containers, err = m.command.GetContainers(m.systemConfig, containerName, false)

internal/app/setup.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,10 @@ func (a *App) addProxyConfig(count int, router *chi.Mux, proxyDef *starlarkstruc
679679
// disabled in proxy config
680680
req.Host = url.Host
681681
}
682-
683682
}
684683

685684
permsHandler := func(p *httputil.ReverseProxy) http.Handler {
686685
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
687-
688686
// If write API, check if preview/stage app is allowed access
689687
isWriteReques := r.Method == http.MethodPost || r.Method == http.MethodPut || r.Method == http.MethodDelete
690688
if isWriteReques {
@@ -696,6 +694,13 @@ func (a *App) addProxyConfig(count int, router *chi.Mux, proxyDef *starlarkstruc
696694
return
697695
}
698696
}
697+
698+
r.Header.Set("X-Forwarded-Host", strings.SplitN(r.Host, ":", 1)[0])
699+
if r.TLS != nil {
700+
r.Header.Set("X-Forwarded-Proto", "https")
701+
} else {
702+
r.Header.Set("X-Forwarded-Proto", "http")
703+
}
699704
// use the reverse proxy to handle the request
700705
p.ServeHTTP(w, r)
701706
})

internal/server/app_apis.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ func (s *Server) verifyClientCerts(r *http.Request, authName string) error {
485485
}
486486

487487
func (s *Server) MatchApp(hostHeader, matchPath string) (types.AppInfo, error) {
488-
s.Trace().Msgf("MatchApp %s %s", hostHeader, matchPath)
488+
//s.Trace().Msgf("MatchApp %s %s", hostHeader, matchPath)
489489
apps, err := s.apps.GetAllApps()
490490
if err != nil {
491491
return types.AppInfo{}, err
@@ -504,7 +504,6 @@ func (s *Server) MatchApp(hostHeader, matchPath string) (types.AppInfo, error) {
504504
// Check if host header matches a known domain
505505
checkDomain := false
506506
if hostHeader != "" && domainMap[hostHeader] {
507-
s.Trace().Msgf("Matched domain %s", hostHeader)
508507
checkDomain = true
509508
}
510509

0 commit comments

Comments
 (0)