Fix scheme issue with X-Forwarded-Proto

This commit is contained in:
Ben Visness 2021-08-30 18:39:24 -05:00
parent e5055a1237
commit 5247afcfc6
2 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,10 @@
file_server {
root /home/hmn/hmn
}
header {
Access-Control-Allow-Origin *
Access-Control-Allow-Methods "GET, OPTIONS"
}
}
handle {
reverse_proxy localhost:9001

View File

@ -144,7 +144,7 @@ func (c *RequestContext) FullUrl() string {
if scheme == "" {
proto, hasProto := c.Req.Header["X-Forwarded-Proto"]
if hasProto {
scheme = fmt.Sprintf("%s://", proto)
scheme = fmt.Sprintf("%s://", proto[0])
}
}
@ -155,6 +155,7 @@ func (c *RequestContext) FullUrl() string {
scheme = "http://"
}
}
return scheme + c.Req.Host + c.Req.URL.String()
}