Skip to content

Commit d71efbd

Browse files
committed
feat: Add subdomain normalization in proxy.go
1 parent 5a24ac6 commit d71efbd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/proxy.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ func NewReverseProxy(schema string, baseDomain string, defaultSubdomain string,
2626
subDomain := req.Header.Get(headerName)
2727
if subDomain == "" {
2828
subDomain = defaultSubdomain
29+
} else {
30+
subDomain = strings.ReplaceAll(strings.ReplaceAll(strings.ToLower(subDomain), "/", "-"), ".", "-")
2931
}
3032
req.URL.Scheme = schema
3133
req.URL.Host = subDomain + "." + baseDomain + ":" + strconv.Itoa(port)
@@ -99,7 +101,7 @@ func (p *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) {
99101

100102
_, err := io.Copy(dst, src)
101103
if err != nil {
102-
slog.Warn("copyResponse, %s", err)
104+
slog.Warn("copyResponse, %v", err)
103105
}
104106
}
105107

0 commit comments

Comments
 (0)