fix: inject Bearer token in API proxy

This commit is contained in:
Claus Lohmar 2026-07-10 13:19:45 +01:00
parent e39d1b9ebd
commit 66eb350564

View file

@ -610,6 +610,11 @@ func initials(s string) string {
func apiProxyHandler(w http.ResponseWriter, r *http.Request) { func apiProxyHandler(w http.ResponseWriter, r *http.Request) {
target, _ := url.Parse("http://127.0.0.1:8080") target, _ := url.Parse("http://127.0.0.1:8080")
proxy := httputil.NewSingleHostReverseProxy(target) proxy := httputil.NewSingleHostReverseProxy(target)
// Inject Bearer token for authelia-api auth
token := os.Getenv("AUTHELIA_SECRET")
if token != "" {
r.Header.Set("Authorization", "Bearer "+token)
}
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/api") r.URL.Path = strings.TrimPrefix(r.URL.Path, "/api")
proxy.ServeHTTP(w, r) proxy.ServeHTTP(w, r)
} }